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:



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





Commands using rm from sorted by
Terminal - Commands using rm - 261 results
rm -rf `find . -type d -name .svn`
find ./ -mtime -5 | xargs rm -f
find . -name *DS_Store -exec echo rm {} \;
2009-03-11 11:30:55
User: dgomes
Functions: echo find rm

This is quite usefull in Unix system share via NFS or AppleTalk with OSX clients that like to populate your filesystem with these pesky files

svn status | grep ^? | awk '{print $2}' | xargs rm -rf
2009-03-10 17:01:40
User: Highwayman
Functions: awk grep rm xargs

Removes all unversioned files and folders from an svn repository. Also:

svn status --no-ignore | grep ^I | awk '{print $2}' | xargs rm -rf

will remove those files which svn status ignores. Handy to add to a script which is in your path so you can run it from any repository (a la 'svn_clean.sh').

sudo find / -iname "*.lproj" -and \! -iname "en*" -print0 | tee /dev/stderr | sudo xargs -0 rm -rfv
2009-03-09 22:08:45
User: asmoore82
Functions: find rm sudo tee xargs

This will get the job done in the most efficient way -

spawning only one `rm` process.

"On-the-fly" find data is displayed through `tee` and

you should have plenty of time to ctrl-c if needed before it's too late.

You may need to re-run this after major Software Updates.

To leave more languages in, add more ``-and \! -iname "lang*"'' statements:

sudo find / -iname "*.lproj" -and \! -iname "en*" -and \! -iname "spanish*" -print0 | tee /dev/stderr | sudo xargs -0 rm -rfv

**Edit: note the 2nd sudo near the end of the pipeline - this is necessary.

find . -name .DS_Store -exec rm {} \;
2009-03-09 13:59:30
User: Svish
Functions: find rm
Tags: Os X

Recursively removes all those hidden .DS_Store folders starting in current working directory.

find -name ".svn" -exec rm -rf {} \;
find /dir_name -mtime +5 -exec rm {} \
2009-03-08 12:03:44
User: eleffie
Functions: find rm
Tags: delete

This command will delete files i a given path (/dir_name) , which older than given time in days (-mtime +5 will delete files older than five days.

find . -type d -name DIR -print0 | xargs -r0 rm -r
2009-03-04 14:49:21
User: miguelbaldi
Functions: find rm xargs
Tags: svn cvs

You can use this command to delete CVS/svn folders on given project.

rm file{1..10}
2009-03-02 14:42:05
User: atoponce
Functions: rm

Rather than typing out all 10 files, you can use brace expansion to do the trick for you. This is useful for backup files, numbered files, or any files with a repeating pattern. Gives more control than 'rm file*' as I might want to keep others around.

git rm $(git ls-files --deleted)
2009-02-26 21:21:02
Functions: rm
Tags: git

This command handles git rm'ing files that you've deleted.

alias wordpress='mkdir wordpress && cd wordpress && wget http://wordpress.org/latest.tar.gz && tar -xvzf latest.tar.gz && mv wordpress/* . && rm -rf latest.tar.gz wordpress && cp wp-config-sample.php wp-config.php'
rm -rf `ls | head -5000`
2009-02-25 22:52:23
User: rockon
Functions: head rm

Deletes thousands of files at one go, I'm not able to recall the exact # of files that rm can delete at one go(apprx. around 7000.)

for x in `find . -name '*.html'` ; do iconv -f ISO-8859-1 -t UTF-8 $x > "$x.utf8"; rm $x; mv "$x.utf8" $x; done
2009-02-25 08:16:01
Functions: iconv mv rm

This is my first attempt at converting all HTML files to UTF-8 file encoding, including all subfolders.

Theres probably a much more compact way to do it, but I'm quite proud of it with my windows background ;)

function miso () { mkdir ~/ISO_CD && sudo mount -o loop "$@" ~/ISO_CD && cd ~/ISO_CD && ls; } function uiso () { cd ~ && sudo umount ~/ISO_CD && rm -r ~/ISO_CD; }
2009-02-25 03:41:35
User: vududevil
Functions: cd mkdir mount rm sudo umount

Add the functions to the .bashrc to make it work

Example: First go to the iso file directory and type:


user@box:~$ miso file.iso


It will put you into a temporary mounting point directory (ISO_CD) and will show the files

You can umount the iso file whatever the directory you are


user@box:~/ISO_CD$ uiso


It wil umount the iso file and remove the temporary directory in your home

FILE="`date +%m%d%H%M%S`.png"; URL="http://YOUR_HOST/YOUR/PATH/$FILE"; TMP="/tmp/$FILE"; import -frame $TMP; scp $TMP YOUR-USER@YOUR-HOST:/YOUR/PATH/; rm $TMP; firefox "$URL"
2009-02-21 18:42:33
User: TheBunman
Functions: rm scp

I often need to send screenshots to other people to explain settings and whatever.

So I created this oneline which I use to create the screenshot with imagemagik, upload it via scp to my server and then the command opens an firefox tab with the screenshot.

The screenshot can be a region or a window.

You just have to replace the parts beginning with YOUR.

doloop() { DONT=/tmp/do-run-run-run; while true; do touch $DONT; (sleep 30; rm $DONT;) & $1 ; if [ -e $DONT ]; then echo restarting too fast; return ; fi ; done }
2009-02-21 02:11:18
User: evil_otto
Functions: echo return rm sleep touch

This runs a command continuously, restarting it if it exits. Sort of a poor man's daemontools. Useful for running servers from the command line instead of inittab.

find . -type d -execdir du -sh '{}' ';' | grep -E "[0-9]+K" | sed 's/^[0-9\.]\+K[\t ]\+//' | tr "\n" "\0" | xargs -0 rm -rf
find . -name .svn | xargs rm -rf
rm ./-filename
2009-02-18 18:36:25
User: starchox
Functions: rm

Using the redundant ./ directory information prevents the dash from occurring at the beginning of the filename, and being interpreted as an option of the rm command.

Also works using:

rm -- -filename
find . -name "*.py[co]" -exec rm -f {} \;
2009-02-18 14:32:28
User: osantana
Functions: find rm

This command will erase all bytecode versions of Python modules under the current directory.

find . | grep deleteme | while read line; do rm $line; done
2009-02-18 00:55:57
User: tec
Functions: find grep read rm

This command deletes all files in all subfolders if their name or path contains "deleteme".

To dry-run the command without actually deleting files run:

find . | grep deleteme | while read line; do echo rm $line; done
find . -name ".svn" -exec rm -rf {} \;
2009-02-17 23:00:30
User: mihaibojin
Functions: find rm

If you need to delete all redundant ".svn" directories from a given path and all its subdirectories, use this command !

Particulary useful if you want to upload to an ftp server, but don't use svn or if you need to update/backup some source code to another directory.

You can also try "svn export . /new/path/without/svn/dirs" (also from the CLI)

find . -name "*.pyc" -exec rm {} \;
2009-02-16 17:15:58
User: nsmgr8
Functions: find rm

For a python project, sometimes I need to clean all the compiled python files. I have an alias 'rmpyc' to this command. This really saves me a lot of typing and hunting throughout the folders to delete those files.

rm -rf `find . -type d -name .svn`
2009-02-16 10:55:57
User: RonaldConco
Functions: rm

This command will remove all .svn folder from your project if you need to manual remove the subversion files.