Hide

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.

Hide

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:

Hide

News

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

Tags

Hide

Functions

Commands by bugmenot from sorted by
Terminal - Commands by bugmenot - 46 results
for i in {0..255} ; do (ping 192.168.1.$i -c 1 > /dev/null && echo "192.168.1.$i" & ) ; done
2014-01-26 18:31:34
User: bugmenot
Functions: echo ping
7

Pings all the hosts on 192.168.1.0/24 in parallel, so it is very fast. Alive host IP addresses are echoed to stdout as pings are responded to.

find /Applications -path '*Contents/_MASReceipt/receipt' -maxdepth 4 -print |sed 's#.app/Contents/_MASReceipt/receipt#.app#g; s#/Applications/##'
2013-09-28 15:44:32
User: bugmenot
Functions: find sed
0

Shows the OS X applications downloaded from App Store. Doesn't include manually added apps.

curl -s $1 | grep -o -i '<a href="//images.4chan.org/[^>]*>' | sed -r 's%.*"//([^"]*)".*%\1%' | xargs wget
2013-07-22 10:33:55
User: bugmenot
Functions: grep xargs
1

first grep all href images then sed the url part then wget

convert infile.png \( +clone -channel GB -evaluate set 0 +channel \) +append -region 50%x100% -channel R -evaluate set 0 +channel outfile.png
2013-04-30 20:46:02
User: bugmenot
Functions: set
0

Converts red-cyan 3D anaglyphs to side-by-side format viewable by crossing your eyes. Useful for people who don't have 3D glasses or prefer not to use one.

cat somefile | tee >(openssl md5 > sum.md5) | bzip2 > somefile.bz2
copy /b part.1 + part.2 + part.n file.extension
cat list.txt | pax -wd > archive.tar
cat /dev/zero | pv -L 3m -Ss 100m > /dev/null
2012-12-15 10:17:52
User: bugmenot
Functions: cat
2

This example will close the pipe after transferring 100MB at a speed of 3MB per second.

lftp -u user,pass ftp://site.com -e 'pget -c -n 6 file'
2012-12-11 16:18:52
User: bugmenot
Functions: lftp
1

This is for files only, for directories 'mirror' has to be used.

for line in `wget --referer='http://500px.com/' --quiet -O- http://500px.com/popular | grep "from=popular" | sed -n 's/.*<img src="\([^"]*\)".*/\1/p' | sed s/"3.jpg"/"4.jpg"/ | sed s/"?t".*$//`; do wget -O $RANDOM.jpg --quiet "$line"; done
2012-12-07 16:14:36
User: bugmenot
Functions: grep sed
0

This command downloads the actual 20 most popular pictures from the website 500px. It uses a random name due to the fact the the pictures in 500px are stored with the same name.

UPDATED: doesn't work if no referrer is specified: --referer='http://500px.com/'

lftp -u user,pass ftp://site.com/ -e 'mirror -c --parallel=3 --use-pget-n=5 "Some folder"'
2012-11-24 11:29:48
User: bugmenot
Functions: lftp
0

It works best if you first login and then do the fetch:

lftp -u user,pass ftp://site.com/

mirror -c --parallel=3 --use-pget-n=5 "Some folder"

star -c -v -f myarchive.tar -no-dirslash list=list.txt
sed -e "s,/\+$,," -e "s,^/\+,," file.txt
2012-11-02 21:08:30
User: bugmenot
Functions: sed
-1

There can be more than one trailing slash, all of them will be removed.

cat file.txt | grep -v /$ > newfile.txt
dd if=mybackup.ab bs=24 skip=1 | openssl zlib -d > mybackup.tar
dd.exe --progress if=\\.\Volume{0b1a0cbe-11da-11c0-ab53-003045c00008} of=pendrive.img
2012-10-13 08:25:48
User: bugmenot
Functions: dd
0

Blocksize (bs) is not mandatory. It's only needed when the count option is specified.

xterm +u8 -fn mtx -maximized -T "There is no spoon!" -e cmatrix -bxa -u 3 & sleep .1s && wmctrl -r :ACTIVE: -b add,fullscreen && transset-df -a &
2012-09-28 04:46:28
User: bugmenot
Functions: sleep
-1
apt-get install cmatrix cmatrix-xfont wmctrl transset-df

Need to restart computer for mtx font to work

Commands while cmatrix is running:

1 - 9 = Change speed

SHIFT + 1 - 7 = change colors

Q = Quit

Tested in Ubuntu 10.04

find ./ -empty -type d -delete
find ./ -empty -type d -print
find ./ -maxdepth 1 -empty -type d -delete
find ./ -maxdepth 1 -empty -type d -print
rd /S /Q directory
sudo shred -vz -n 0 /dev/sdb
dir /ad /s /b