All commands (14,187)

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. 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.

Share Your Commands


Check These Out

Send an email from the terminal when job finishes
Might as well include the status code it exited with so you know right away if it failed or not.

Watching Command
If you need to keep an eye on a command whose output is changing, use the watch command. For example, to keep an eye on your load average

Quick directory bookmarks
Set a bookmark as normal shell variable $ p=/cumbersome/path/to/project To go there $ to p This saves one "$" and is faster to type ;-) The variable is still useful as such: $ vim $p/ will expand the variable (at least in bash) and show a list of files to edit. If setting the bookmarks is too much typing you could add another function $ bm() { eval $1=$(pwd); } then bookmark the current directory with $ bm p

Replace space in filename
This commands removes space from all the files with specific extension. I've specifed *.jpg as an example.

Prints total line count contribution per user for an SVN repository
make usable on OSX with filenames containing spaces. note: will still break if filenames contain newlines... possible, but who does that?!

Download an Entire website with wget

Delete empty, 24-hours-old directories recursively, without consider hidden directories

Sum columns from CSV column $COL
More of the same but with more elaborate perl-fu :-)

Create a bash script from last commands
In order to write bash-scripts, I often do the task manually to see how it works. I type ### at the start of my session. The function fetches the commands from the last occurrence of '###', excluding the function call. You could prefix this with a here-document to have a proper script-header. Delete some lines, add a few variables and a loop, and you're ready to go. This function could probably be much shorter...

calculate the total size of files in specified directory (in Megabytes)


Stay in the loop…

Follow the Tweets.

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.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

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: