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 uniq from sorted by
Terminal - Commands using uniq - 212 results
ps aux | sort --key=11 | uniq -c -d --skip-fields=10 | sort -nr --key=1,1
2011-07-19 07:11:29
User: aikikode
Functions: ps sort uniq
2

This command will allow to search for duplicate processes and sort them by their run count. Note that if there are same processes run by different users you'll see only one user in the result line, so you'll need to do:

ps aux | grep <process>

to see all users that run this command.

exiv2 *JPG | grep Focal | awk '{print $5}' | sort -n | uniq -c
2011-07-05 11:25:29
User: ivanatora
Functions: awk grep sort uniq
-1

First column is number of photos, second column is the focal length.

netstat -nt | awk -F":" '{print $2}' | sort | uniq -c
netstat -ntu | awk ' $5 ~ /^[0-9]/ {print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
2011-07-04 20:23:21
User: letterj
Functions: awk cut netstat sort uniq
Tags: netstat
-4

netstat has two lines of headers:

Active Internet connections (w/o servers)

Proto Recv-Q Send-Q Local Address Foreign Address State

Added a filter in the awk command to remove them

netstat -ntu | awk ' $5 ~ /^[0-9]/ {print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
netstat -nt | awk '{print $6}' | sort | uniq -c | sort -n -k 1 -r
tcpdump -nr capture.file | awk '{print }' | grep -oE '[0-9]{1,}.[0-9]{1,}.[0-9]{1,}.[0-9]{1,}' | sort | uniq -c | sort -n
2011-06-16 19:27:11
User: shahabv
Functions: awk grep sort tcpdump uniq
Tags: tcpdump
0

We can get useful statistics from tcpdump with this simple command.

Thanks "Babak Farrokhi" to teaching me this ;)

netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
cut -f1 -d" " ~/.bash_history | sort | uniq -c | sort -nr | head -n 30
find /path/to/dir -type f |sed 's/^.*\.//' |sort -f |uniq -i
ps -eo stat= | sort | uniq -c | sort -n
2011-03-25 13:01:42
User: fossilet
Functions: ps sort uniq
0

Use ps instead of top. But do not use BSD options at all, they are confusing.

Use "s=" or "state=" to show consice process statuses.

cat /backup/hd7/rdiff-log.txt |grep Processing | awk '{ print $4 }' | sed -e 's/\// /g' | awk '{ print $1 }' |uniq -c |sort -n
history | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -n | tail | sort -nr
yum whatprovides /usr/lib/libXX1.so /usr/lib/libXX2.so | grep fc | sed 's/^\(.*\)-[0-9.]*-.*$/\1/' | sort | uniq | xargs yum -y install
2011-03-07 04:51:35
User: laputa
Functions: fc grep sed sort uniq xargs
0

this command will install the packages which provides the libraries you need to link with, e.g. when you compile something needs opengl libraries:

gcc -o testgl testgl.c -lGLEW -lGL -lGLU -lglut

you can use `/usr/lib/libGLEW.so /usr/lib/libGL.so /usr/lib/libGLU.so /usr/lib/libglut.so'

find . -type f | awk -F'.' '{print $NF}' | sort| uniq -c | sort -g
cat YOUR_FILE|tr -d '[:punct:]'|tr '[:upper:]' '[:lower:]'|tr -s ' ' '\n'|sort|uniq -c|sort -rn
users | xargs -n1 echo | sort | uniq -c
svn log -q | grep '^r[0-9]' | cut -f2 -d "|" | sort | uniq -c | sort -nr
2011-01-03 15:23:08
User: kkapron
Functions: cut grep sort uniq
2

list top committers (and number of their commits) of svn repository.

in this example it counts revisions of current directory.

wget -qO - http://ngrams.googlelabs.com/datasets | grep -E href='(.+\.zip)' | sed -r "s/.*href='(.+\.zip)'.*/\1/" | uniq | while read line; do `wget $line`; done
(netstat -atn | awk '{printf "%s\n%s\n", $4, $4}' | grep -oE '[0-9]*$'; seq 32768 61000) | sort -n | uniq -u | head -n 1
history | awk '{print $2,$3}' | sed s/sudo// | awk '{print $1}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -n | tail | sort -nr
2010-11-17 12:15:04
User: b_t
Functions: awk sed sort tail uniq
0

Your version works fine except for someone who's interested in commands 'sudo' was prefixed to

i.e. in your command, use of sudo appears as number of times sudo was used.

Slight variation in my command peeks into what commands sudo was used for and counts the command

(ignores 'sudo')

history | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -n | tail | sort -nr
tr -cs A-Za-z '\n' | sort | uniq -ci
2010-10-20 04:12:58
Functions: sort tr uniq
Tags: sort uniq tr
0

Gives the same results as the command by putnamhill using nine less characters.

tr A-Z a-z | tr -cs a-z '\n' | sort | uniq -c
tr A-Z a-z | tr -d "[[:punct:]][[:digit:]]" | tr ' /_' '\n' | sort | uniq -c