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.

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



Psst. Open beta.

Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:

  • » The open beta is running a copy of the database that will not carry over to the final version. Don't post anything you don't mind losing.
  • » If you wish to use your user account, you will probably need to reset your password.
Your feedback is appreciated via the form on the beta page. Thanks! -Jon & CLFU Team

Commands using xargs from sorted by
Terminal - Commands using xargs - 641 results
locate -0 -i *barthes* | xargs -0 mv -t ~/'Library/Books/Barthes, Roland'
2014-11-16 18:26:35
User: qdrizh
Functions: locate mv xargs
Tags: mv xargs locate

Find all books on my systems and move them into folder. The -0 switches are to handle spaces etc. in the filenames.

Why would you need this? Locate uses an index, so it's super quick, and xargs is more elegant than a for loop.

python -c "import pip; print(' '.join([x.project_name for x in pip.get_installed_distributions()]))" | xargs sudo pip install -U
brew outdated | cut -f1 | xargs brew upgrade
2014-11-16 09:51:50
User: wires
Functions: cut xargs

You probably want to run `brew update` before you run this command

ls *.png | cut -d . -f 1 | xargs -L1 -i convert -strip -interlace Plane -quality 80 {}.png {}.jpg
find . -name *.png | xargs optipng -nc -nb -o7 -full
git branch -r | awk -F'/' '{print "git fetch "$1,$2}' | xargs -I {} sh -c {}
find . -name '*.jar' | xargs -l jar vtf | grep XXX.java
find -not -empty -type f -printf "%-30s'\t\"%h/%f\"\n" | sort -rn -t$'\t' | uniq -w30 -D | cut -f 2 -d $'\t' | xargs md5sum | sort | uniq -w32 --all-repeated=separate
2014-10-19 02:00:55
User: fobos3
Functions: cut find md5sum sort uniq xargs

Finds duplicates based on MD5 sum. Compares only files with the same size. Performance improvements on:

find -not -empty -type f -printf "%s\n" | sort -rn | uniq -d | xargs -I{} -n1 find -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w32 --all-repeated=separate

The new version takes around 3 seconds where the old version took around 17 minutes. The bottle neck in the old command was the second find. It searches for the files with the specified file size. The new version keeps the file path and size from the beginning.

gcloud components list | grep "^| Not" | sed "s/|\(.*\)|\(.*\)|\(.*\)|/\2/" | xargs echo gcloud components update
2014-10-13 20:52:25
User: wires
Functions: echo grep sed xargs

Google Cloud SDK comes with a package manager `gcloud components` but it needs a bit of `sed` to work. Modify the "^| Not" bit to change the package selection. (The gcloud --format option is currently broken)

find . -iname "*.mp4" -print0 | xargs -0 mv --verbose -t /media/backup/
finger $(whoami) | egrep -o 'Name: [a-zA-Z0-9 ]{1,}' | cut -d ':' -f 2 | xargs echo
2014-09-24 01:22:07
User: swebber
Functions: cut egrep finger xargs

Its possible to user a simple regex to extract de username from the finger command.

The final echo its optional, just for remove the initial space

find . -name "*.pdf" -print0 | xargs -r0 stat -c %y\ %n | sort|awk '{print $4}'|gawk 'BEGIN{ a=1 }{ printf "mv %s %04d.pdf\n", $0, a++ }' | bash
2014-09-23 06:40:45
Functions: awk find gawk printf stat xargs
Tags: sort awk find xargs

Caution: distructive overwrite of filenames

Useful for concatenating pdfs in date order using pdftk

docker images | grep '' | awk '{print $3}' | xargs docker rmi
docker ps -a | grep 'Exit' | awk '{print $1}' | xargs docker rm
[ `curl 'http://crl.godaddy.com/gds5-16.crl' 2>/dev/null | openssl crl -inform DER -noout -nextupdate | awk -F= '{print $2}' | xargs -I{} date -d {} +%s` -gt `date -d '8 hours' +%s` ] && echo "OK" || echo "Expires soon"
2014-08-07 17:18:38
User: hufman
Functions: awk date echo xargs
Tags: openssl

Downloads a CRL file, determines the expiration time, and checks when it will expire

find /var/log -type f -iregex '.*[^\.][^0-9]+$' -not -iregex '.*gz$' 2> /dev/null | xargs tail -n0 -f | ccze -A
2014-07-29 17:11:17
User: rubo77
Functions: find tail xargs
Tags: unix ccze logging

This will show all changes in all log files under /var/log/ that are regular files and don't end with `gz` nor with a number

docker ps -q | xargs -n 1 docker inspect | jq '.[0].NetworkSettings.Ports +{} | map(select(. != null)[0].HostPort) | map("-L \(.):localhost:\(.)") ' | sed -n 's/.*"\(.*\)".*/\1/p' |xargs boot2docker ssh -N
echo {-1..-5}days | xargs -n1 date +"%Y-%m-%d" -d
find . |xargs grep '<html\|<body\|<table' |sed '/~/d;s/:.*//' |sed 's/.*/mv & &.html/' |uniq >run.sh; sh run.sh
find -type f -iregex '.*\.\(mkv\|mp4\|wmv\|flv\|webm\|mov\|dat\|flv\)' -print0 | xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null | perl -nle '/ID_LENGTH=([0-9\.]+)/ && ($t +=$1) && printf "%02d:%02d:%02d\n",$t/3600,$t/60%60,$t%60' | tail -n 1
2014-06-07 15:50:41
User: powerinside
Functions: find perl printf tail xargs

Use case insensitive regex to match files ending in popular video format extensions and calculate their total time. (traverses all files recursively starting from the current directory)

find . -type d -d 1 -print0 | xargs -0 du -sm | sort -nr
dig MX example.com +short | cut -d' ' -f2 | sed '1q;d' | xargs dig +short
for d in `ls -d *`; do svn status $d | awk '{print $2}'; done | xargs ls -l {} \;
2014-05-27 19:07:45
User: dronamk
Functions: awk ls xargs

Find all files in SVN workspace directories which are uncommitted. List them and find their properties

git status --porcelain | sed -ne 's/^ M //p' | tr '\n' '\0' | tr -d '"' | xargs -0 vim
2014-05-08 08:36:27
User: uschrisf
Functions: sed tr xargs
Tags: vim git

Works even with spaces in filenames.

As an alias in .gitconfig:


editchanged = "!git status --porcelain | sed -ne 's/^ M //p' | tr '\\n' '\\0' | tr -d '\"' | xargs -0 vim"

find . -name '*.phtml' | xargs perl -pi -e 's/(?!(<\?(php|xml|=)))<\?/<\?php/g;'
2014-05-07 14:33:19
User: crashspeeder
Functions: find perl xargs

Tired of front end developers using short open tags in your views? This will replace all instances of