commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for:
rename file name with fixed length nomeric format pattern
Renames all files in a directory named foo to bar.
foobar1 gets renamed to barbar1
barfoo2 gets renamed to barbar2
fooobarfoo gets renamed to barobarfoo
NOTE: Will break for files with spaces AND new lines AND for an empty expansion of the glob '*'
Command to install everything on a debian based system with the prefix you indicate.
if Argument list too long
So you are in directory with loads of pictures laying around and you need to quickly scan through them all
The result of this command is a tar with all files that have been modified/added since revision 1792 until HEAD. This command is super useful for incremental releases.
print sum of disk usage for filetype within current dir and subdirs
for when find . -print | grep -v .svn | xargs doesnt cut it.
This one-liner will use strace to attach to all of the currently running apache processes output and piped from the initial "ps auxw" command into some awk.
Deletes capistrano-style release directories (except that there are dashes between the YYYY-MM-DD)
One of my friends committed his code in the encoding of GB2312, which broke the build job. I have to find his code and convert.
this command will install the packages which provides the libraries you need to link with, e.g. when you compile something needs opengl libraries:
gcc -o testgl testgl.c -lGLEW -lGL -lGLU -lglut
you can use `/usr/lib/libGLEW.so /usr/lib/libGL.so /usr/lib/libGLU.so /usr/lib/libglut.so'
Look mah! All pipes
Take a folder full of files and split it into smaller folders containing a maximum number of files. In this case, 100 files per directory.
find creates the list of files
xargs breaks up the list into groups of 100
for each group, create a directory and copy in the files
Note: This command won't work if there is whitespace in the filenames (but then again, neither do the alternative commands :-)
This should handle whitespaces well and will not get confused if your filenames have "?" in them
In the file data.txt there is a single column of numbers. Sed adds a "+" between lines and xargs prepares the output for bc. The "echo 0" is to avoid to have a "+" at the beginning of the line.
root@wow/var/spool/clientmqueue # rm spam-*
/bin/rm: Argument list too long.