What's this?

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.

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

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.

Credits

Psst. Open beta.

Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:

» The open beta is running a copy of the database that will not carry over to the final version. Don't post anything you don't mind losing.

» If you wish to use your user account, you will probably need to reset your password.

Your feedback is appreciated via the form on the beta page. Thanks! -Jon & CLFU Team

**NOTE** Tekhne's alternative is much more succinct and its output conforms to the files actual contents rather than with white space removed

My command on the other hand uses bash process substitution (and "Minimal" Perl), instead of files, to first remove leading and trailing white space from lines, before diff'ing the streams. Very useful when differences in indentation, such as in programming source code files, may be irrelevant

[email protected]:~/shellcode$ perl -e 'print "\x41\x72\x74\x20\x6f\x66\x20\x68\x61\x63\x6b\x69\x6e\x67\x2e\x2e\x2e\n" x 100'
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
Art of hacking...
[email protected]:~/shellcode$

In this example, file contains five columns where first column is text. Variance is calculated for columns 2 - 5 by using perl module Statistics::Descriptive. There are many more statistical functions available in the module.

Using perl you can search for patterns spanning several lines, a thing that grep can't do. Append the list of files to above command or pipe a file through it, just as with regular grep. If you add the 's' modifier to the regex, the dot '.' also matches line endings, useful if you don't known how many lines you need are between parts of your pattern. Change '*' to '*?' to make it greedy, that is match only as few characters as possible.

This shell function grabs the weather forecast for the next 24 to 48 hours from weatherunderground.com. Replace <YOURZIPORLOCATION> with your zip code or your "city, state" or "city, country", then calling the function without any arguments returns the weather for that location. Calling the function with a zip code or place name as an argument returns the weather for that location instead of your default.

To add a bit of color formatting to the output, use the following instead: