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.

Universal configuration monitoring and system of record for IT.
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

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

Top Tags

Hide

Functions

Hide

Credits

Commands using rm from sorted by
Terminal - Commands using rm - 260 results
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
1

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

eg:

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
0

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

find . -size 1400c -exec rm {} \;
2011-08-18 15:19:24
User: gef
Functions: find rm
0

Removes all files in the current folder that are 1400 bytes in size.

find . -name "directory_name" -type d -print0 | xargs -0 -i rm -rf {}
find . -type d -name 'CVS' -exec rm -r {} \;
find . -type d -name 'CVS' | xargs rm -r
rm -R `ls | egrep -v 'dir1|dir2|file1'`
wget http://somesite.com/somestream.pls; cvlc somestream.pls&sleep 5; rm somestream.pls*
2011-08-04 19:24:18
User: tomjrace
Functions: rm wget
-1

I wanted to play a song from the shell and get the shell back, I also dont want to store the file if it is not needed.

edit, not sure if I need to mention it... killall vlc to stop it

rm -- -i
2011-07-26 04:00:32
User: merlinblack
Functions: rm
0

If you just try rm -i, the file name will be interpreted as a command line switch. Many commands let you use a double hyphen '--' to say 'No more switches, the rest are file names'.

Incidentally having a file named '-i' in a directory where you use rm * will cause rm to act as if you specified '-i' on the command line.

vim -- -v touch -- -t cat -- -c
find . -name .svn -type d | parallel rm -rf
rm !(*.txt)
for i in *.tar.gz; do tar -x -v -z -f $i && rm -v $i; done
for i in "*.txt"; do tar -c -v -z -f $i.tar.gz "$i" && rm -v "$i"; done
function rm { workingdir=$( pwdx $$ | awk '{print $2}' ) /usr/bin/rm $* echo "rm $* issued at $(date) by the user $(who am i| awk '{print $1} ') in the directory ${workingdir}" >> /tmp/rm.out }
2011-06-22 14:47:38
User: soulonfire
Functions: awk echo rm
1

Sometimes, it is annoying to find your files or directories missing. If you want to log all the rm commands you can put this in /etc/profile.

adobenospy() { for I in ~/.adobe ~/.macromedia ; do ( [ -d $I ] && rm -rf $I ; ln -s -f /dev/null $I ) ; done }
2011-06-08 14:34:52
User: Timothy
Functions: ln rm
0

A safer way to block adobe and macromedia flash tracking and spyware

git ls-files -z -d | xargs -0 git rm --
rm -rf /bin/laden
for arq in *.png; do size=$(identify $arq | cut -f3 -d" "); [ $size == "280x190" ] || rm $arq ; done
2011-04-22 20:00:05
Functions: cut rm
Tags: ImageMagick
1

Removes all png files whose geometry is not 280x190 pixels

yt-pl2mp3() {umph -m 50 $1 | cclive -f mp4_720p; IFS=$(echo -en "\n\b"); for track in $(ls | grep mp4 | awk '{print $0}' | sed -e 's/\.mp4//'); do (ffmpeg -i $track.mp4 -vn -ar 44100 -ac 2 -ab 320 -f mp3 $track.mp3); done; rm -f *.mp4}
2011-03-20 14:43:20
User: sattellite
Functions: awk echo grep ls rm sed
0

umph is parsing video links from Youtube playlists ( http://code.google.com/p/umph/ )

cclive is downloading videos from Youtube ( http://cclive.sourceforge.net/ )

Example:

yt-pl2mp3 7AB74822FE7D03E8
locate munin | xargs rm -r
rm -r .[!.]*
rm -rf .[!.]*
rm -rf .??*
2011-03-11 07:21:58
User: greggster
Functions: rm
Tags: rm dot
0

rm -rf .* matches ".." and thus one goes up a level and wipes out more than intended.

In bash, .??* safely accomplishes what one intends - remove those .files

The ? matches most characters except "/", thus .?? does not match ../ and so one is safe.

find . -maxdepth 1 -type d | grep -Pv "^.$" | sort -rn --field-separator="-" | sed -n '3,$p' | xargs rm -rf
git filter-branch --index-filter 'git rm --cached --ignore-unmatch FileToRemove' HEAD