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 cat from sorted by
Terminal - Commands using cat - 443 results
while true; do date; (curl -s -o 1.html http://www.biglion.ru/deals/ebay-80/ &); sleep 5; cat 1.html | grep "&#1082;&#1091;&#1087;&#1086;&#1085;&#1086;&#1074;" | awk -F"<div>" '{print $2}' | awk -F"<span>" '{print $1}'; done
2013-11-08 12:40:05
User: sxiii
Functions: awk cat grep sleep

Processes biglion quantity of sold ebay coupons/bonus codes, so you can know approximate count of users who buyed the coupons and when sales are come up again.

You can change sleep parameter so script will work slowly or faster (default is 5 seconds).

Additional requirements: curl

Standart tools used: awk, date, cat, grep (bash)

find ./ -type f -size +500k -exec ls -1Ash {} \; | sort -hr | cat -n
2013-10-01 10:32:28
User: rgregor
Functions: cat find ls sort

"find ./ ..." could be replaced with "find $PWD ..." to display absolute path instead of relative path.

du -ah | sort -hr | head -n50 | cat -n
echo '#! /usr/bin/ksh\ncat $2 | openssl dgst -sha256 | read hashish; if [[ $hashish = $1 ]]; then echo $2: OK; else echo $2: FAILED; fi;' > shacheck; chmod +x shacheck; cat hashishes.sha256 | xargs -n 2 ./shacheck;
2013-09-18 21:51:20
User: RAKK
Functions: cat chmod echo read xargs

This command is used to verify a sha256sum-formatted file hash list on IBM AIX or any other UNIX-like OS that has openssl but doesn't have sha256sum by default. Steps:

1: Save to the filesystem a script that:

A: Receives as arguments the two parts of one line of a sha256sum listing

B: Feeds a file into openssl on SHA256 standard input hash calculation mode, and saves the result

C: Compares the calculated hash against the one received as argument

D: Outputs the result in a sha256sum-like format

2: Make the script runnable

3: Feed the sha256sum listing to xargs, running the aforementioned script and passing 2 arguments at a time

cat /dev/cdrom > ~/img.iso
cat /dev/zero > /dev/sda
2013-09-13 21:47:48
User: fhh
Functions: cat

Exactly the same effect with 3 less characters ;-) (Removes all files/filesystems of a harddisk. It removes EVERYTHING of your hard disk. Be careful when to select a device.)

You can press Ctrl + C after few seconds

(No output)

cat /var/log/apache2/access_logs | cut -d' ' -f1 | sort | uniq -c | sort -n
2013-09-07 23:57:31
User: while0pass
Functions: cat cut sort uniq

The first sort is necessary for ips in a list to be actually unique.

cat part1.avi part2.avi part3.avi > tmp.avi && mencoder -forceidx -oac copy -ovc copy tmp.avi -o output.avi && rm -f tmp.avi
2013-09-05 01:47:22
User: sudopeople
Functions: cat rm

Useful for when you download movies split into < 700mb parts.

Credit to rich @ http://superuser.com/questions/318640/merge-avi-files-without-recoding-in-mac-os-x-lion

mencoder is generally included with mplayer.


sudo port install mplayer
cat /var/log/apache2/access_logs | cut -d ' ' -f 1 | uniq -c | sort -n
2013-09-02 13:04:47
User: basvdburg
Functions: cat cut sort uniq

Show's per IP of how many requests they did to the Apache webserver

cat file{0..5} > mainfile
2013-08-17 04:15:45
User: snipertyler
Functions: cat

After splitting a file, put them all back together a lot faster then doing

cat file1 file2 file3 file4 file5 > mainfile


for i in {0..5}; do cat file$i > mainfile; done

When splitting, be sure to do split -d

for getting numbers instead of letters

colordiff <(ssh [email protected] cat /etc/ssh/sshd_config) /etc/ssh/sshd_config
find /usr/include/ -name '*.[c|h]pp' -o -name '*.[ch]' -print0 | xargs -0 cat | grep -v "^ *$" | grep -v "^ *//" | grep -v "^ */\*.*\*/" | wc -l
2013-06-17 08:37:37
Functions: cat find grep wc xargs

Count your source and header file's line numbers. This ignores blank lines, C++ style comments, single line C style comments.

This will not ignore blank lines with tabs or multiline C style comments.

cat filein | ssh destination.com -c arcfour,blowfish-cbc -C -p 50005 "cat - > /tmp/fileout"
2013-05-30 07:18:46
User: bhbmaster
Functions: cat ssh
Tags: cat ssh

Where filein is the source file, destination.com is the ssh server im copying the file to, -c arcfour,blowfish-cbc is selecting the fastest encryption engines, -C is for online compressions and decompression when it comes off the line - supposed to speed up tx in some cases, then the /tmp/fileout is how the file is saved...

I talk more about it on my site, where there is more room to talk about this:




diff /path/to/localfile <(ssh [email protected] cat /path/to/remotefile)
2013-05-24 09:24:31
User: mc0e
Functions: cat diff ssh

Or, if you have restricted access for sftp only, I think you can still do this:

diff /path/to/localfile <(scp [email protected]:/path/to/remotefile >(cat))
cat domainlist.txt | while read line; do echo -ne $line; whois $line | grep Expiration ; done | sed 's:Expiration Date::'
cat file.gz.cpt *[a-z] | ccdecrypt -k yoursecretpassword | tar -xzf -
cat /dev/ttyS2 | hexdump -C
cat foo.json | python -mjson.tool
2013-05-06 20:11:05
User: jeffgage
Functions: cat python
Tags: json

For situations where you keep JSON in a VCS and you want your diffs to be sane, such as within a Chef configuration repo.

cat -n install.log | head -88 | tac | head -n $(( 88 - 50 )) | tac
cat -n install | head -n 150 | tac | head -n 50 | tac
cat $HISTFILE | grep command
cat data.json >data.yml
2013-04-25 04:09:58
User: Mozai
Functions: cat
Tags: json yaml

Valid JSON is a subset of YAML; no transformation is necessary; however, YAML has many syntax features that are not valid JSON, so you can't do the reverse as easily.

OIFS=$IFS;IFS=$':';for i in $(cat -n /etc/passwd);do echo -n $i\ ** \ ;done
cat .bash_history | tail -100 | grep {command}
2013-04-10 10:40:52
User: techie
Functions: cat grep tail

I know how hard it is to find an old command running through all the files because you couldn't remember for your life what it was. Heres the solution!! Grep the history for it. depending on how old the command you can head or tail or if you wanted to search all because you cannot think how long ago it was then miss out the middle part of the command. This is a very easy and effective way to find that command you are looking for.

rm index.html | wget www.google.com;cat index.html | sed 's/<script>/\n\n\<script>\n\n/g' | sed 's/<\/script>/>\n\n/g'
2013-04-10 04:05:30
User: lbhack
Functions: cat rm sed wget

remove old index.html if you download it again and organiaz the java script tag on the file index.html