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.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

Universal configuration monitoring and system of record for IT.

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:



May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!

Top Tags



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

Get the weather forecast for the next 24 to 48 for your location.

Terminal - Get the weather forecast for the next 24 to 48 for your location.
weather(){ curl -s "http://api.wunderground.com/auto/wui/geo/ForecastXML/index.xml?query=${@:-<YOURZIPORLOCATION>}"|perl -ne '/<title>([^<]+)/&&printf "%s: ",$1;/<fcttext>([^<]+)/&&print $1,"\n"';}
2010-02-10 01:23:39
User: eightmillion
Functions: perl
Get the weather forecast for the next 24 to 48 for your location.

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:

weather(){ curl -s "http://api.wunderground.com/auto/wui/geo/ForecastXML/index.xml?query=${@:-<YOURZIPORLOCATION>}"|perl -ne '/<title>([^<]+)/&&printf "\x1B[0;34m%s\x1B[0m: ",$1;/<fcttext>([^<]+)/&&print $1,"\n"';}

Requires: perl, curl


There are 11 alternatives - vote for the best!

Terminal - Alternatives
weather() { curl -s "http://www.wunderground.com/q/zmw:$1.1.99999" | grep "og:title" | cut -d\" -f4 | sed 's/&deg;/ degrees F/'; }
curl -s http://api.wunderground.com/auto/wui/geo/ForecastXML/index.xml?query=${@:-<YOURZIPORLOCATION>}|xmlstarlet sel -E utf-8 -t -m //forecast/txt_forecast/forecastday -v fcttext -n
2010-04-13 22:14:48
User: fanfani

you can use xmlstarlet to parse output instead of perl

Know a better way?

If you can do better, submit your command here.

What others think

doesn't work:

[email protected]:~$ cat weather

weather(){ curl -s "

[email protected]:~$ perl weather

syntax error at weather line 1, near "){"

Execution of weather aborted due to compilation errors.

[email protected]:~$ ./weather

[email protected]:~$ weather(){ curl -s "

bash: syntax error near unexpected token `('

Comment by leftyfb 350 weeks ago

leftyfb, it's not a script. You need to enter it at as a function at your shell, or add it to a file that gets sourced by your shell such as ~/.bashrc. Try pasting it at the bottom of your ~/.bashrc file and then source your bashrc with the command "source ~/.bashrc". After that you should be able to just type weather at your prompt to call it. Just make sure that you change <YOURZIPORLOCATION> to your location, like "89110" or "eugene, or".

Comment by eightmillion 350 weeks ago

A decent one line weather app after a long time. Thanks.

Comment by billbose 350 weeks ago

still not working:


Comment by leftyfb 349 weeks and 6 days ago

leftyfb, what version of bash are you using? I've tested this on recent versions of ash, bash, dash, ksh, and zsh and didn't have any problems on any of them.

Comment by eightmillion 349 weeks and 6 days ago

Doe not work.

Comment by chinmaya 349 weeks and 1 day ago

works on snow leopard on mac:

bradleym-contegix:~ bradleymccrorey$ weather(){ curl -s "

Tonight: Cloudy with a 40 percent chance of rain and snow. Low in the lower 30s. Southeast wind around 10 mph.

Saturday: Cloudy. High in the mid 40s. South wind around 10 mph in the morning becoming light in the afternoon.

TOTALLY pimp. That's going in my .bash_profile

Comment by 4fthawaiian 348 weeks and 4 days ago

Very cool - thank you.

How can I get rid of the &?

October 5, 2013: Overcast. High 10&deg;C (50&deg;F). Winds 14 kph SSW

October 6, 2013: Chance of Rain. High 12&deg;C (53&deg;F). Winds 14 kph SSW

Comment by GrouchyGaijin 159 weeks and 4 days ago

This worked up until the last day or two (either that or I exceeded the max number of API calls). It seems that command re-directs you to the terms and agreement of their API now.

It seems the proper url now is: http://www.wunderground.com/?apiref= where apiref= is your API key. I'm working on coming up with a pure Bash way of parsing the output (using grep awk cut and tr), but it's a slog.

Comment by sophiejane 70 weeks and 1 day ago

Your point of view

You must be signed in to comment.