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

Get all links from commandlinefu front page
You need to install WWW::Mechanize Perl module with # cpan -i WWW::Mezchanize or by searching mechanize | grep perl in your package manager With this command, you can get forms, images, headers too

Find top 10 largest files in /var directory (subdirectories and hidden files included )
Same as above, but modified to show human readable output

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

Generate MD5 of string and output only the hash checksum in a readable format
Generates the md5 hash, without the trailing " -" and with the output "broken" into pairs of hexs.

Convert unix timestamp to date
The "-d" option for gnu's "date" command can calculate positive or negative offset from any time, including "now". You can even specify a source timezone (the output timezone can be set with the TZ environment variable). Useful! Fun! Not very well documented!

Customize time format of 'ls -l'
the --time-style argument to 'ls' takes several possible modifiers: full-iso, long-iso, iso, locale, +FORMAT. The +FORMAT modifier uses the same syntax as date +FORMAT. --time-style=+"%Y-%m-%d %H:%M:%S" strikes a happy medium between accuracy and verbosity: $ ls -lart --time-style=long-iso doesn't show time down to the nearest second, $ ls -lart --time-style=full-iso displays time to 10E-9 second resolution, but with no significant digits past the full seconds, also showing the timezone: $ -rw-r--r-- 1 bchittenden bchittenden 0 2011-02-10 12:07:55.000000000 -0500 bar

Find usb device in realtime
Using this command you can track a moment when usb device was attached.

Write comments to your history.
A null operation with the name 'comment', allowing comments to be written to HISTFILE. Prepending '#' to a command will *not* write the command to the history file, although it will be available for the current session, thus '#' is not useful for keeping track of comments past the current session.

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...

worse alternative to
worse alternative to ctrl+r: grep the history removing duplicates without sorting (case insensitive search).


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: