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 sed from sorted by
Terminal - Commands using sed - 1,156 results
ls -1F | grep @$ | sed 's/@//' | column
2013-07-19 17:55:11
User: jlbknr
Functions: grep ls sed
Tags: ls symlinks

I use this with alias:

alias lsl="ls -1F | grep @$ | sed 's/@//' | column"

Limitation: This will also list files that happen to have an @ at the end of the filename.

$ ls -1F | grep @ | sed 's/@//' | column
2013-07-19 17:41:03
User: jlbknr
Functions: grep ls sed
Tags: ls symlinks

I use this with alias:

alias lsl="ls -1F | grep @ | sed 's/@//' | column"

uptime | awk -F ',' ' {print $1" "$2}'|awk ' {print $3" "$4" "$5}' | sed '1,$s/:/ /' | awk ' {if ($4 =="user") print $1*60 + $2;else if ($2=="mins") print $1;else print $1*24*60 + $2*60 + $3}'
2013-07-19 13:28:29
User: tatgren
Functions: awk sed uptime
Tags: uptime minutes

find the uptime and convert in minutes, works with AIX and Linux too

find ./ -type f | sed "s:[\ \',\"]:\\\&:g" | xargs md5sum
2013-07-17 18:54:14
User: crazedsanity
Functions: find sed xargs

Recursively list all files in the current directory & get their md5sum, even if the filename has bad characters.

cut -d, -f1 /var/opt/example/dumpfile.130610_subscriber.csv | cut -c3-5 | sort | uniq -c | sed -e 's/^ *//;/^$/d' | awk -F" " '{print $2 "," $1}' > SubsxPrefix.csv
2013-07-17 07:58:56
User: neomefistox
Functions: awk cut sed sort uniq
Tags: Linux UNIX

dumpfile is a CSV file, which its 1st field is a phone number in format CC+10 digits

Empty lines are deleted, before the output in format "prefix,ocurrences"

ps aux | grep $(echo $1 | sed "s/^\(.\)/[\1]/g")
2013-07-16 10:10:51
User: opexxx
Functions: echo grep ps sed
Tags: sed grep ps

grep по ps aux

find . -type d | sed -e "s/[^-][^\/]*\// |/g" -e "s/|\([^ ]\)/|-\1/"
2013-07-16 10:08:34
User: opexxx
Functions: find sed
Tags: sed find

show directory three

curl --silent http://www.census.gov/population/international/ | grep wclocknum | sed -r 's@^.*>([0-9,]+)<.*$@\1@'
2013-07-15 22:35:05
User: malathion
Functions: grep sed
Tags: curl

Deprecated due to a change in the site design: see alternatives.

lynx --dump twitter.com/(username) | sed -n "132,134 p"
2013-07-06 16:28:10
User: xmuda
Functions: sed

I was using some twitter bots and twitter bloks my IP. Now im using some proxys and i use these command to validate the tweet was published.

leo (){ l="en"; if [ "${1:0:1}" = "-" ]; then l=${1:1:2};shift;fi;Q="$*";curl -s "https://dict.leo.org/${l}de/?search=${Q// /%20}" | html2text | sed -e '0,/H.ufigste .*/d;/Weitere Aktionen/,$d;/f.r Sie .*:/,$d' | grep -aEA900 '^\*{5} .*$'; }
2013-06-24 22:35:46
User: michelsberg
Functions: grep sed

Translate strings from non-german to german (and vice versa) using LEO. Put it in your ~/.bashrc.


leo words

To use another language other than english, use an option:

leo -xx words

Valid language options:

ch - chinese

en - english

es - spanish

fr - french

it - italian

pl - polish

pt - portuguese

ru - russian

The other language will always be german!

wget -qO - whatismyipaddress.com/ip/<type ip address> | grep -E "City:|Country:" | sed 's:<tr><th>::'| sed 's</th>::' | sed 's:</td>::' | sed 's:</tr>::' | sed 's:<img*::'
2013-06-21 03:27:09
User: pentester
Functions: grep sed wget

This command will help you to get Ip address origin of city and country.

I will be happy if someone can shrink the sed command


watch -t -c -n30 'wget -q -O- "http://wwwapps.ups.com/WebTracking/processInputRequest?TypeOfInquiryNumber=T&InquiryNumber1=1Z4WYXXXXXXXXXX" | html2text | sed -n "/Shipment Progress/,/Shipping Information/p" | grep -v "*" | ccze -A'
netstat -tn | awk '{print $5}' | egrep -v '(localhost|\*\:\*|Address|and|servers|fff|127\.0\.0)' | sed 's/:[0-99999999].*//g'
2013-06-13 14:35:38
User: kehansen
Functions: awk egrep netstat sed

I used this to get all the remote connection ip addresses connected to my server... I had to start storing and tracking this data so thats why i built this out... probably not optimal as far as the egrep regex but it works ;)

sudo /usr/sbin/exim -bp | sed -n '/\*\*\* frozen \*\*\*/,+1!p' | awk '{print $1}' | tr -d [:blank:] | grep @ | sort | uniq -c | sort -n
ls -1 | while read file; do new_file=$(echo $file | sed s/\ /_/g); mv "$file" "$new_file"; done
find -name '*.mp3' -exec mp3info {} -p "%F: %r kbps\n" \; | sort | sed '/320 kbps/d'
find . -type f -name filename.exe -exec sed -i "s/oldstring/oldstring/g" {} +;
curl -s http://www.reddit.com/user/$USER/about.json | tr "," "\n" | grep "link_karma" | tr ": " "\n" | grep -E "[0-9]+" | sed s/"^"/"Link Karma: "/
2013-05-13 15:36:59
User: iiAtlas
Functions: grep sed tr
Tags: curl

Replace $USER with the username of the Reddit user in question. To get comment karma instead run...

curl -s http://www.reddit.com/user/$USER/about.json | tr "," "\n" | grep "comment_karma" | tr ": " "\n" | grep -E "[0-9]+" | sed s/"^"/"Comment Karma: "/
cat domainlist.txt | while read line; do echo -ne $line; whois $line | grep Expiration ; done | sed 's:Expiration Date::'
sed -n '1!G;h;$p' techie.txt
pathrm() { PATH=`echo $PATH | sed -re 's#(:|^)cde($|:)#:#g;s#^:##g;s#:$##g'`; }
sudo sed -i 's/Exec=skype %U/Exec=skype --disable-cleanlooks -style GTK %U/' /usr/share/applications/skype.desktop
2013-04-17 08:43:00
User: FadeMind
Functions: sed sudo

Replace default command in skype.desktop file.

sudo sed -i 's/raspberrypi/pita1/' /etc/hosts /etc/hostname; sudo reboot
2013-04-16 07:27:41
User: egeoffray
Functions: sed sudo

Your computer's name is raspberrypi and you want to rename it to pita1.

This command will change both the hostname and the name used for netwrk communications.

uniq -c | sed -r 's/([0-9]+)\s(.*)/"\2": \1,/;$s/,/\n}/;1i{'
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