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:
Deletes files in the current directory or its subdirectories that match "regexp" but handle directories, newlines, spaces, and other funky characters better than the original #13315. Also uses grep's "-q" to be quiet and quit at the first match, making this much faster. No need for awk either.
Grep can search files and directories recursively. Using the -Z option and xargs -0 you can get all results on one line with escaped spaces, suitable for other commands like rm.
After this command you can review doit.sh file before executing it.
If it looks good, execute: `. doit.sh`
Using "wmic get * /value" within any Cygwin shell will return lots of Win/Dos newline junk ie "^M$" at the end of found value line, two lines ("$" Unix newline) above, and three below. This makes storing and or evaluating wmic queries as variables a pain. The method i suggest strips the mentioned junk, only returns the value after "OSArchitecture=", and includes only one Unix style newline. Other methods using sed|awk|cut can only handle the output of wmic cleanly when piped or using multiple sed statements.
wmic OS get OSArchitecture /value | sed 's/\r//g;s/^M$//;/^$/d;s/.*=//'
wmic OS get OSArchitecture /value | grep -Eo '[^=]*$'
a much cleaner and slightly less costly alternative.
on some distro's you have to replace "BogoMIPS" with "bogomips".
This will highlight (with a box over it) any changes since the last refresh.
-c will count the number of times your search matches in the file.
Replace "foo" with "bar" in all files in current directory recursively
For when you are initializing your repos on a new machine and feeling paranoid about it.
This script can be used to download enclosed files from a RSS feed. For example, it can be used to download mp3 files from a podcasts RSS feed.
Puts a splash of color in your access logs. IP addresses are gray, 200 and 304 are green, all 4xx errors are red. Works well with e.g. "colorize access_log | less -R" if you want to see your colors while paging.
Use as inspiration for other things you might be tailing, like syslog or vmstat
tail -f access.log | colorize
Pipes the header row of ps to STDERR, then greps for the command on the output of ps, removing the grep entry before that.
Extracts date taken from image and renames it properly.
Based on StackOverflow answer.
first grep all href images then sed the url part then wget
grep по ps aux
This will catch most separators in the section of the email:
plus + (added for gmail)
... and the basic dash '-' of host names.
This command is useful for searching through a whole folder worth of pdf files.