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.

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:



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 rm from sorted by
Terminal - Commands using rm - 259 results
find /SOME/PATH -type f -execdir rm -f {} \+
2012-06-15 05:32:31
User: kiiwii
Functions: find rm
Tags: find rm

rm /SOME/PATH/*, when you hit "argument list too long".

ls -ltr |grep 'May 12'|awk '{print $9;}'|xargs rm -v
find . -name '.svn' -type d | xargs rm -rf
2012-05-18 10:26:55
User: luckymurari
Functions: find rm xargs

This simple command removes all the .svn directories recursively. Useful when you want to get a clean code excluding .svn files.

Check what is getting delete through this command

" find . -name '.svn' -type d | xargs echo "

find . -name ._\* -exec rm -f {} \;
2012-05-14 22:25:42
User: silicontrip
Functions: find rm
Tags: find rm

This command won't delete resource forks from an HFS file system, only from file systems that don't natively support resource forks.

find . -iname ".svn" | xargs rm -r $1
rm *(L0)
ls -s|grep -E "^ *0"|sed "s/^ *0 //g"|xargs -i rm "{}"
2012-04-18 14:50:46
User: glaudiston
Functions: grep ls rm sed xargs

Remove all zero size files from current directory. Its a not recursive option like:

find . -size 0c -exec rm {} \;

man -t ls > ls.ps && pdf2ps ls.ps && rm ls.ps
find . -type f -name "*.*" -exec cat {} > totalLines 2> /dev/null \; && wc -l totalLines && rm totalLines
find . -name ".#*" -exec rm {} \;
2012-03-07 17:05:47
User: jialin
Functions: find rm

Remove all the hidden CVS merge helper files that I keep seeing in my IntellIj project

find -name *.lock |xargs rm -f
2012-03-07 04:48:03
User: mpax
Functions: find rm xargs

This command removes *.lock or files from a folder.

cmdfu(){ local t=~/cmdfu;echo -e "\n# $1 {{{1">>$t;curl -s "commandlinefu.com/commands/matching/$1/`echo -n $1|base64`/plaintext"|sed '1,2d;s/^#.*/& {{{2/g'>$t;vim -u /dev/null -c "set ft=sh fdm=marker fdl=1 noswf" -M $t;rm $t; }
2012-02-21 05:43:16
User: AskApache
Functions: echo rm sed vim

Here is the full function (got trunctated), which is much better and works for multiple queries.

function cmdfu () {

local t=~/cmdfu;

until [[ -z $1 ]]; do

echo -e "\n# $1 {{{1" >> $t;

curl -s "commandlinefu.com/commands/matching/$1/`echo -n $1|base64`/plaintext" | sed '1,2d;s/^#.*/& {{{2/g' | tee -a $t > $t.c;

sed -i "s/^# $1 {/# $1 - `grep -c '^#' $t.c` {/" $t;



vim -u /dev/null -c "set ft=sh fdm=marker fdl=1 noswf" -M $t;

rm $t $t.c


Searches commandlinefu for single/multiple queries and displays syntax-highlighted, folded, and numbered results in vim.

ls|grep .mp3 >list.txt; while read line; do newname=`echo $line|sed 's/\ /-/g'|sort`; newname=`echo $newname|tr -s '-' `; echo $newname; echo $newname>> tracklist.txt;mv "$line" "$newname"; done <list.txt; rm list.txt
x="/tmp/auth.html";sudo cat /var/log/auth.log | logtool -o HTML >$x;xdg-open $x;rm $x
2012-02-09 13:36:21
Functions: cat rm sudo

similar to previous except this exports to a temporary file, opens that file with your default web browser, then deletes it.

rm -rf /commands/by/fukr
for FILE in `ls -1`; do if [ -L "$FILE" ]; then cp $(readlink "$FILE") ${FILE}_rf; rm -f $FILE; mv ${FILE}_rf "$FILE"; fi; done
man -t man | ps2pdf - temp.pdf; evince temp.pdf &> /dev/null &; sleep 3; rm temp.pdf
2011-12-08 17:40:47
User: threv
Functions: man rm sleep

Yeah yeah, another "render man page in pdf", but this time it creates a temporary PDF that stays resident in memory for viewing, but is eliminated on the filesystem.

Replace evince with your PDF viewer of choice.

cmdfu(){ local TCF="/var/tmp/cmdfu"; echo " Searching..."; curl "http://www.commandlinefu.com/commands/matching/$(echo "$@" | sed 's/ /-/g')/$(echo -n $@ | base64)/plaintext" --silent > "$TCF"; vim -c "set filetype=sh" -RM "$TCF"; rm "$TCF"; }
ls -1 $PATH*/* | xargs file | awk -F":" '!($2~/PDF document/){print $1}' |xargs rm -rf
find $SDIR -name '${f}.*' -mtime +$n -maxdepth 1 | xargs -n 10 rm -vf
unzip -l filename.zip |awk '{ if($4 != "Name" && $4 != "----") print $4}'|xargs -t rm -rf {}
2011-10-20 18:54:15
User: hk0i
Functions: awk rm xargs
Tags: awk xargs unzip rm

Sometimes you unzip a file that has no root folder and it spews files all over the place. This will clean up all of those files by deleting them.

svn status|grep -iR '^!'|sed 's/!/ /g'|xargs -i svn rm '{}'
2011-10-06 08:11:25
User: erdeszt
Functions: grep rm sed xargs
Tags: svn sed xargs grep

Helps if you accidentally deleted files from an svn repo with plain rm and you would like to mark them for svn to delete too.

find /path/folder -type f -name "*.*" -print -exec rm -v {} + | wc -l;
2011-09-19 14:53:37
User: Koobiac
Functions: find rm wc

It does not work without the verbose mode (-v is important)

switchMonitor () { LF=/tmp/screen-lock; if [ -f $LF ]; then rm $LF; else touch $LF; sleep .5; while [ -f $LF ]; do xset dpms force off; sleep 2; done; fi };
2011-08-26 17:55:44
User: totti
Functions: rm sleep touch

Use the command to create a script and bind it to a key using keyboard shortcut.


Script locks the screen in a loop until the command is executed again.At first it

c=blue;convert -size 50x50 xc:$c $c.png; for i in red green yellow; do convert $c.png -background $i -rotate 20 $i.png; rm $c".png"; c=$i; done; mv $i".png" logo.png; display logo.png
2011-08-21 15:59:11
User: Funatiker
Functions: mv rm
Tags: ImageMagick

Deletes unneeded files after every step and allows to use a color other than yellow at the last position.