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.




All commands from sorted by
Terminal - All commands - 11,926 results
echo 'ibase=10; obase=2; 127' | bc
grep -r "sampleString" . |uniq | cut -d: -f1 | xargs sed -i "/sampleString/d"
2009-02-09 20:21:30
User: sk1418
Functions: cut grep sed xargs

checking files in current and sub directories, finding out the files containing "sampleString" and removing the containing lines from the file.

* Beware that The command will update the original file [no backup].

The command can be extended if play with 'find' command together,

e.g. it is possible to execute on certain type of files: *.xml, *.txt... (find -name "*.xml" | grep....)

if anybody knows a better solution on that, please drop a comment. thx.

poweriso convert image.daa -o image.iso -ot iso
accurev stat -M -fl | awk '{print "\"" $0 "\""}' | xargs accurev pop
git merge-base branch1 branch2
git merge --no-commit --no-ff
2009-02-09 18:59:26
User: Pistos
Functions: merge

Will do the merge, but only apply changes to working copy and index; won't commit.

date -d 09/20/1981 +"%Y-%m-%d"
awk '{ FS = OFS = "#" } { if ($9==1234) print }' filename*.log > bigfile.log
sed -n 's/[ :]/_/g; s/^\(.\{1,\}\)_5_\($1$[$./0-9A-Za-z]\{27,31\}\)_*$/\1:\2/p' < cisco-device-config > passwd
alias ip4rev "echo \!* | sed 's/^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\4.\3.\2.\1/'"
2009-02-09 17:00:03
Functions: alias

For 'bash'

function ip4rev() { echo $@ | sed 's/^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\4.\3.\2.\1/'; }
PROMPT=$'%{\e[0;32m%}%B[%b%{\e[0m%}%n%{\e[0;32m%}@%{\e[0m%}%(4c,./%1~,%~)%{\e[0;32m%}%B]%b% %(?,%{\e[0;32m%}:%)%{\e[0m%},%{\e[0;31m%}:(%{\e[0m%}) %# '
alias ip4grep "grep -E '([0-9]{1,3}\.){3}[0-9]{1,3}'"
cat -n file.txt
tidy -asxhtml -numeric < index.html > index.xml
find . \( -name '*.h' -o -name '*.cc' \) | xargs grep . | wc -l
2009-02-09 11:44:35
User: dgomes
Functions: find grep wc xargs

Counts number of lines of code in *.h and *.cc files

svn st | cut -c 8- | sed 's/^/\"/;s/$/\"/' | xargs tar -czvf ../backup.tgz
2009-02-09 11:24:31
User: chrisdrew
Functions: cut sed tar xargs

Create a tgz archive of all the files containing local changes relative to a subversion repository.

Add the '-q' option to only include files under version control:

svn st -q | cut -c 8- | sed 's/^/\"/;s/$/\"/' | xargs tar -czvf ../backup.tgz

Useful if you are not able to commit yet but want to create a quick backup of your work. Of course if you find yourself needing this it's probably a sign you should be using a branch, patches or distributed version control (git, mercurial, etc..)

pkill -HUP syslogd
convert +adjoin animatedImage.gif test.gif ; convert +append test*.gif
echo 16i `echo "F" | tr '[a-f]' '[A-F]'` p | dc ; echo 16o "15" p | dc
sed -e '/^[<space><tab>]*$/d' somefile
enscript -E -B -3 -r -s 0 --borders -fCourier4.8 --mark-wrapped-lines=arrow
2009-02-09 06:23:38
User: mkc

This is the setup I'm using for my largest project. It gives 357 lines per page (per side), which makes it fairly easy to carry around a significant amount of code on a few sheets of paper. Try it.

(I stick to the 80 column convention in my coding. For wider code, you'll have to adjust this.)

alias pfind='ps aux | grep '
alias ::='cd ../../'
find ~/random_jpegs/folder -name "*.jpg" -exec rdjpgcom {} \;
2009-02-09 02:58:13
User: Williebee
Functions: find

depends on libjpeg-progs

But how to display path to found comments?