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

Print out a man page
man -t manpagename gives a postscript version of said man page. You then pipe it to ls, and assuming you have cups set up, it prints in your default printer.

Rapidly invoke an editor to write a long, complex, or tricky command
Next time you are using your shell, try typing $ ctrl-x ctrl-e # in emacs mode or $ v # in vi mode The shell will take what you've written on the command line thus far and paste it into the editor specified by $EDITOR. Then you can edit at leisure using all the powerful macros and commands of vi, emacs, nano, or whatever.

Emergency Alien Invasion Warning
When aliens invade Earth, be first to warn your neighbours by placing your computer screen at a window and executing this potentially Earth-saving command. Ctrl C when aliens are defeated.

split a file by a specific number of lines
Splits the file "my_file" every 500 lines. Will create files called xx01 xx02 and so on. You can change the prefix by using the -f option. Comes in handy for splitting logfiles for example. I am using it for feeding a logfile parser with smaller files instead of one big file (due to performance reasons)

Ping all hosts on 192.168.1.0/24
-b option takes the broadcast address.

convert filenames in current directory to lowercase
The simplest way I know.

Convert CSV to JSON
Replace 'csv_file.csv' with your filename.

finding cr-lf files aka dos files with ^M characters
Looking for carriage returns would also identify files with legacy mac line endings. To fix both types: $ perl -i -pe 's/\r\n?/\n/g' $(find . -type f -exec fgrep -l $'\r' "{}" \;)

List upcoming events on google calendar
Requires googlecl (http://code.google.com/p/googlecl/) Even better when you wrap this in a script and allow the --date=STRING to be $1. Then you can type: whatson "next Thursday" The date string for UNIX date is very flexible. You can also add --cal "[regex]" to the end for multiple calendars.

Get My Public IP Address


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: