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.

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.

UpGuard checks and validates configurations for every major OS, network device, and cloud provider.

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 xargs from sorted by
Terminal - Commands using xargs - 642 results
find . -iname ".svn" | xargs rm -r $1
find . -type f -name *.MP3 -print0 | xargs -0 -i rename .MP3 .mp3 {}
2012-04-29 02:44:44
User: pibarnas
Functions: find rename xargs

Using a for loop, rename all files with .MP3 extension to .mp3.

ps afx | grep defunct -B 1 | grep -Eo "[0-9]{3,}" | xargs kill -9
2012-04-27 16:16:34
User: pholz
Functions: grep kill ps xargs

defunct processes (zombies) usually have to be killed by killing their parent processes. this command retrieves such zombies and their immediate parents and kills all of the matching processes.

wget -O - http://www.reddit.com/r/wallpapers.rss | grep -Eo 'http://i.imgur.com[^&]+jpg' | head -1 | xargs wget -O background.jpg
2012-04-25 11:15:26
User: untitaker
Functions: grep head wget xargs

Doesn't depend on curl and doesn't use thumbnails as wallpaper (which has the unfortunate effect of only allowing imgur links)

find . -user root | xargs sudo chown me:me
2012-04-24 18:29:13
Functions: chown find sudo xargs

be careful where you execute this from

do a 'sudo ls' beforehand to prime sudo to not ask for your password

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 {} \;

git remote -v | grep fetch | sed 's/\(.*github.com\)[:|/]\(.*\).git (fetch)/\2/' | awk {'print "https://github.com/" $1'} | xargs open
2012-04-15 20:48:46
User: brockangelo
Functions: awk grep sed xargs

Written for Mac OSX. When you are working in a project and want to open it on Github.com, just type "gh" and your default browser will open with the repo you are in. Works for submodules, and repo's that you don't own.

You'll need to copy / paste this command into a gh.sh file, then create an alias in your bash or zsh profile to the gh.sh script. Detailed instructions here if you still need help:


svn stat | grep ^\! | awk '{print $2}' | xargs svn del
2012-04-13 12:13:37
Functions: awk grep stat xargs

Sometimes cache-files or garbage gets added to your SVN repository. This is the way I normally clean up those when the actual files are already gone.

find ./src -type d -name "Entity" | xargs ls -A | cut -d . -f1 | sed 's_^_app/console doctrine:generate:entities YourOwnBundleName:_'
2012-04-11 21:28:02
User: renoirb
Functions: cut find ls sed xargs

When I do a major change in my entities, I want to find a way to find all my Entities names and create the commande for me.

So instead of doing ls src/Your/OwnBundle... and then do it manually, this helps a lot.

find . -type f -print0 | xargs -0 -n1 md5sum | sort -k 1,32 | uniq -w 32 -d --all-repeated=separate | sed -e 's/^[0-9a-f]*\ *//;'
find . -type f -print0 | xargs -0 du -h | sort -hr | head -20
2012-03-30 10:21:12
User: flatcap
Functions: du find head sort xargs

Search for files and list the 20 largest.

find . -type f

gives us a list of file, recursively, starting from here (.)

-print0 | xargs -0 du -h

separate the names of files with NULL characters, so we're not confused by spaces

then xargs run the du command to find their size (in human-readable form -- 64M not 64123456)

| sort -hr

use sort to arrange the list in size order. sort -h knows that 1M is bigger than 9K

| head -20

finally only select the top twenty out of the list

find . -mount -type f -printf "%k %p\n" | sort -rg | cut -d \ -f 2- | xargs -I {} du -sh {} | less
svn stat | grep M | cut -d " " -f8 | xargs svn revert
find . -type f -print0 | xargs -0 chmod -v gu=rw
2012-03-22 03:08:53
User: Tobbera
Functions: chmod find xargs
Tags: chmod files

This command finds all files in a folder recursively and sets owner and group to read and write. Leaves all dirs intact. This command does takes care of file names with spaces as well.

ps h --ppid $(cat /var/run/apache2.pid) | awk '{print"-p " $1}' | xargs sudo strace
2012-03-21 01:59:41
Functions: awk cat ps sudo xargs

Like the original version except it does not include the parent apache process or the grep process and adds "sudo" so it can be run by user.

adb shell ps | grep my.app.packagename | awk '{print $2}' | xargs -I ? sh -c "adb logcat -v time | grep ?"
find . -type f ! -perm /u+x -printf "\"%p\"\n" | xargs file | grep -i executable
2012-03-12 17:29:36
User: aaronjcopley
Functions: file find grep xargs

Helps to fix permissions when a user clobbers them in their home directory or elsewhere. Does not rely on file extension, but uses the `file` command for context.

find /path/to/dir -iname "*.ext" -print0 | xargs -0 mplayer -really-quiet -cache 64 -vo dummy -ao dummy -identify 2>/dev/null | awk '/ID_LENGTH/{gsub(/ID_LENGTH=/,"")}{SUM += $1}END{ printf "%02d:%02d:%02d\n",SUM/3600,SUM%3600/60,SUM%60}'
2012-03-11 12:28:48
User: DarkSniper
Functions: awk find printf xargs

Improvement on Coderjoe's Solution. Gets rid of grep and cut (and implements them in awk) and specifies some different mplayer options that speed things up a bit.

ls | grep -i mp3 | sort -R | sed -e 's/.*/"&"/' | xargs mpg123
2012-03-10 20:51:36
User: retrodanny
Functions: grep ls sed sort xargs

* grep -i leaves only mp3 files (case insentitive)

* sort -R randomizes list (may use GNU 'shuf' instead).

* the sed command will add double quotes around each filename (needed if odd characters are present)

find / -type f -name IMG_????.JPG -print0 |xargs -0 exiv2 -g Exif.Canon.ModelID '{}' |grep A520 |rev |cut --complement -d " " -f1-40 |rev |xargs -I {} cp --parents {} /where
2012-03-10 03:01:01
User: fladam
Functions: cp cut find grep rev xargs

You must spezify /where folder and / folder

If you have another camera you must experiment with Exif data (after -g and after grep) and mask of your photo files IMG_????.JPG

I have do it on Knoppix 6.7.0

You must have installed exiv2.

aptitude -F "%p" search \!~M~i~T | xargs apt-mark markauto
2012-03-09 13:44:00
User: gspadari
Functions: xargs

Marks all manually installed deb packages as automatically installed. Usefull to combine with

apt-get install <all manually packages that we want>

to have a clean installed debian-based system.

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.

adb shell ps | grep <process name> | awk '{print $2}' | xargs adb shell kill
2012-03-03 01:03:39
Functions: awk grep ps xargs

This is great when you need to reboot the system-server, or your own daemon that has gone crazy

find <directory> -type f -printf "%T@\t%p\n"|sort -n|cut -f2|xargs ls -lrt
ls -ltr --directory $(find . -regex "./.*[^/]*\'" -type f | xargs -n 1 dirname | sort | uniq)
2012-03-02 03:48:47
User: pdkl95
Functions: dirname find ls sort xargs

This let me find some a set of modifications that were made to a rather large tree of files, where the file-names themselves were not unique (actually: insanely redundant and useless. "1.dat 2.dat ..."). Pruning down to last-branch brough things back to the "project-name" scope, and it's then easy to see which branches of the tree have recently changed, or any other similar search.

Ideally, it should sort the directories by the mtime of the most recent *file* *inside* the directory, but that's probably outside the scope of a (sane...) command line.