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.

If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

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.


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:



2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.




Commands using wget from sorted by
Terminal - Commands using wget - 238 results
wget -O - 'https://USERNAMEHERE:PASSWORDHERE@mail.google.com/mail/feed/atom' --no-check-certificate
2010-09-26 14:47:13
User: PLA
Functions: wget

I use this command in my Conky script to display the number of messages in my Gmail inbox and to list the from: and subject: fields.

wget -q $(lynx --dump 'http://geekandpoke.typepad.com/' | grep '\/.a\/' | grep '\-pi' | head -n 1 | awk '{print $2}') -O geekandpoke.jpg
wget -O- -q http://www.nomachine.com/download-package.php?Prod_Id=2067 | sed -n -e 'H;${x;s/\n/ /g;p;}' | sed -e "s/[Hh][Rr][Ee][Ff]=\"/\n/g" | cut -d "\"" -f1 | sort -u | grep deb$
wget -k -r -l 5 http://gentoo-install.com
2010-09-03 01:42:50
User: fecub
Functions: wget

Download Websites to 5 Level and browse offline!

-k -> convert-links (to browse offline)

-r -> recursive download

-l 5 -> level 5




translate() { echo $1: $(wget -q -O - 'http://www.google.de/dictionary?source=translation&q='$1'&langpair=en|de' | grep '^<span class="dct-tt">.*</span>$' | sed 's!<span class="dct-tt">\(.*\)</span>!\1, !'); }
2010-09-02 00:08:06
User: fpunktk
Functions: echo grep sed wget

the google-api gives you only one translation which is sometimes insufficent. this function gives you all translations, so you can choose which one fits best.

wget http://forums.dropbox.com && wget $(cat index.html|grep "Latest Forum Build"|cut -d"\"" -f2) && wget $(cat topic.php*|grep "Linux x86:"|cut -d"\"" -f2|sort -r|head -n1) && rm -rf ~/.dropbox* && rm index.html *.php* && tar zxvf dropbox-*.tar.gz -C ~/
xkcd() { wget -qO- http://xkcd.com/ | sed -n 's#^<img src="\(http://imgs.[^"]\+\)"\s\+title="\(.\+\?\)"\salt.\+$#eog "\1"\necho '"'\2'#p" | bash ; }
2010-08-25 15:44:31
User: John_W
Functions: bash sed wget

This function displays the latest comic from xkcd.com. One of the best things about xkcd is the title text when you hover over the comic, so this function also displays that after you close the comic.

To get a random xkcd comic use the following:

xkcdrandom() { wget -qO- http://dynamic.xkcd.com/comic/random | sed -n 's#^<img src="\(http://imgs.[^"]\+\)"\s\+title="\(.\+\?\)"\salt.\+$#eog "\1"\necho '"'\2'#p" | bash; }

These are just a bit shorter than the ones eigthmillion wrote, however his version didn't work as expected on my laptop for some reason (I got the title-tag first), so these build a command which is executed by bash.

wget -k $URL
2010-08-21 17:39:53
User: minnmass
Functions: wget
Tags: wget

The "-k" flag will tell wget to convert links for local browsing; it works with mirroring (ie with "-r") or single-file downloads.

wget -qO - www.commandlinefu.com/commands/random | grep "<div class=\"command\">" | sed 's/<[^>]*>//g; s/^[ \t]*//; s/&quot;/"/g; s/&lt;/</g; s/&gt;/>/g; s/&amp;/\&/g'
2010-08-12 23:58:24
User: smop
Functions: grep sed wget
Tags: random

retrieves the html from a random command line fu page, then finds commands on the page and prints them

alternatively, pipe to bash (add "| bash" to the end) to execute the command (very risky)

edit: had to adjust to properly display the portion that replaces HTML characters (e.g. &quot; -> ")

wget -qO- ifconfig.me/ip
2010-08-05 12:04:43
User: glaudiston
Functions: wget
Tags: ip address

alternative to

curl ifconfig.me

for those that don't have curl

wget --quiet -O - checkip.dyndns.org | sed -e 's/[^:]*: //' -e 's/<.*$//'
2010-08-01 13:36:08
User: berkes
Functions: sed wget
Tags: ip address

Wgets "whatismyip" from checkip.dyndns.org and filters out the actual IP-adress. Usefull when you quickly need to find the outward facting IP-address of your current location.

wget http://www.whatismyip.org --quiet -O - | cat
wget -qO - http://www.google.com | tee >(md5sum) > /tmp/index.html
2010-07-23 06:29:29
User: jianingy
Functions: tee wget

other options:

* replace md5sum with sha1sum for SHA1 checksum

* replace '>' with '| tar zx' for extracting tarball

wget --load-cookies <cookie-file> -c -i <list-of-urls>
wget randomfunfacts.com -O - 2>/dev/null|grep \<strong\>|sed "s;^.*<i>\(.*\)</i>.*$;\1;"|cowsay -f tux
wget -O - http://www.commandlinefu.com/commands/browse/rss 2>/dev/null | awk '/\s*<title/ {z=match($0, /CDATA\[([^\]]*)\]/, b);print b[1]} /\s*<description/ {c=match($0, /code>(.*)<\/code>/, d);print d[1]} ' | grep -v "^$"
2010-06-29 16:22:03
User: nikunj
Functions: awk grep wget
Tags: awk grep meta

A Quick variation to the latest commands list with the new-lines skipped. This is faster to read.

wget -qO- icanhazip.com
2010-06-24 03:49:14
Functions: wget

Curl is not installed by default on many common distros anymore. wget always is :)

wget -qO- ifconfig.me/ip
wget -qO - "http://ajax.googleapis.com/ajax/services/language/translate?langpair=|zh-cn&v=1.0&q=`xsel`" |cut -d \" -f 6
wget -qO - "http://ajax.googleapis.com/ajax/services/language/translate?langpair=|en&v=1.0&q=`xsel`" |cut -d \" -f 6
2010-06-04 17:20:17
User: fain182
Functions: cut wget

Uses google api to translate, you can modify the language in which translate modifying the parameter "langpair=|en", the format is language input|language output.

wget -qO - sometrusted.web.site/tmp/somecommand | sh
2010-06-01 01:25:21
User: UnixSage
Functions: wget

This is a simple command that you can run complex shell scripts via ssh. For instance if you would have to run the same process on several hundred hosts. There is no security so you have to trust the server that is sourcing this script.

cd /some/empty/folder/website_diffs/sitename && wget -N http://domain.com/ 2>&1 |grep -q "o newer" || printf "Sites web page appears to have updated.\n\nSuggest you check it out.\n\n"|mail -s "Sites page updated." david@email.com
2010-05-09 07:28:42
User: DaveQB
Functions: cd grep mail printf wget

A cronjob command line to email someone when a webpages homepage is updated.

translate() { lng1="$1";lng2="$2";shift;shift; wget -qO- "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=${@// /+}&langpair=$lng1|$lng2" | sed 's/.*"translatedText":"\([^"]*\)".*}/\1\n/'; }
kaffeine $(wget -qO- "http://questions-pour-un-champion.france3.fr/emission/index-fr.php?page=video&type_video=quotidiennes&video_courante=$(date +%Y%m%d)" | grep -o "mms.*wmv" | uniq)
2010-04-29 17:59:06
User: fbone
Functions: grep wget

kaffeine could be replaced by any player able to read mms stream

mv ubuntu-10.04-rc-desktop-amd64.iso ubuntu-10.04-desktop-amd64.iso; i=http://releases.ubuntu.com/10.04/ubuntu-10.04-desktop-amd64.iso.zsync; while true; do if wget $i; then zsync $i; date; break; else sleep 30; fi; done
2010-04-29 15:49:43
Functions: mv sleep wget

Need to have rc iso pre-downloaded before running command.

while true; do if wget http://releases.ubuntu.com/10.04/ubuntu-10.04-desktop-i386.iso.torrent; then ktorrent --silent ubuntu-10.04-desktop-i386.iso.torrent ; date; break; else sleep 5m; fi; done
2010-04-29 13:22:54
User: ppaschka
Functions: sleep wget

Tested with 9.10 release. Choose whatever torrent client you prefer.