
Terminal - Commands using uniq - 145 results
cat /var/log/nginx/access.log | grep -oe '^[0-9.]\+' | perl -ne 'system("geoiplookup $_")' | grep -v found | grep -oe ', [A-Za-z ]\+$' | sort | uniq -c | sort -n
This is sample output - yours may be different.
71 , Poland
116 , France
300 , United States
2426 , Spain
Per country GET report, based on access log. Easy to transform to unique IP
for a in $(find . -xdev -type f -printf '%i\n'|sort|uniq -d);do find . -xdev -inum $a -printf '%s %i %m %n %U %G %AD %Ar %p\n';done|sort -n|awk '{if(x!=$2){print "---"};x=$2;print $0}'
This is sample output - yours may be different.
157 10840 644 2 1000 1000 04/09/12 02:23:44 PM ./bookmarks.xml
157 10840 644 2 1000 1000 04/09/12 02:23:44 PM ./mydir/bookmarks.xml
---
1987 10845 644 3 1000 1000 04/09/12 02:23:44 PM ./kst.gif
1987 10845 644 3 1000 1000 04/09/12 02:23:44 PM ./mydir/neki.gif~
1987 10845 644 3 1000 1000 04/09/12 02:23:44 PM ./mydir/text.gif
---
1988 10846 644 2 1000 1000 04/09/12 02:23:44 PM ./mydir/neki1.gif
1988 10846 644 2 1000 1000 04/09/12 02:23:44 PM ./mydir/neki.gif
The listing will be nice separated with dashes in chunks of identical files.
Output format:
Size Inode Mode Count_of_identical_files UID GID Date Time Path/Filename
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]*\ *//;'
This is sample output - yours may be different.
history | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -nr | head
This is sample output - yours may be different.
find /some/path -type f -and -printf "%f\n" | egrep -io '\.[^.]*$' | sort | uniq -c | sort -rn
This is sample output - yours may be different.
.m3u
.M3U
.m4a
.m4v
.mp3
.Mp3
.MP3
the
find -printf "%f\n" prints just the file name from the given path. This means directory paths which contain extensions will not be considered.
head -n1 nation.tbl | sed 's/\(.\)/\1\n/g' | sort | uniq -c | grep \| | awk '{ print $1 }'
This is sample output - yours may be different.
cat z.log | cut -d ':' -f1,2 | uniq -c
This is sample output - yours may be different.
6 2012-02-24 11:26
10 2012-02-24 11:27
8 2012-02-24 11:28
7 2012-02-24 11:29
7 2012-02-24 11:30
8 2012-02-24 11:31
7 2012-02-24 11:32
7 2012-02-24 11:33
9 2012-02-24 11:34
9 2012-02-24 11:35
8 2012-02-24 11:36
depends on date format locale ...
cat z.log | cut -d ':' -f1 | sort | uniq | xargs -l1 -iFF echo 'echo FF $(cat z.log | grep -e "^FF" | grep -e Timeout | wc -l )' | bash
This is sample output - yours may be different.
2012-02-24 08 28
2012-02-24 09 122
2012-02-24 10 110
2012-02-24 11 95
cat z.log | grep Timeout | cut -d ':' -f1 | sort | uniq -c
This is sample output - yours may be different.
28 2012-02-24 08
122 2012-02-24 09
110 2012-02-24 10
95 2012-02-24 11
useful to count events in logs
sed -e 's/[;|][[:space:]]*/\n/g' .bash_history | cut --delimiter=' ' --fields=1 | sort | uniq --count | sort --numeric-sort --reverse | head --lines=20
This is sample output - yours may be different.
awk -F: '{print $3}' /etc/passwd | sort |uniq -d
This is sample output - yours may be different.
user@host:/etc# awk -F: '{print $3}' /etc/passwd | sort |uniq -d
203
user@host:/etc#
Detect duplicate UID in you /etc/passwd (or GID in /etc/group file).
Duplicate UID is often forbidden for it can be a security breach.
find . -type f -exec md5 '{}' ';' | sort | uniq -f 3 -d | sed -e "s/.*(\(.*\)).*/\1/"
This is sample output - yours may be different.
This works on Mac OS X using the `md5` command instead of `md5sum`, which works similarly, but has a different output format. Note that this only prints the name of the duplicates, not the original file. This is handy because you can add `| xargs rm` to the end of the command to delete all the duplicates while leaving the original.
history | sed -e 's/^sudo //' | awk '{print $2}' | sort | uniq -c | sort -rn | head
This is sample output - yours may be different.
I make an extensive use of sudo, so I had to exclude the sudo part of the command history
history | awk '{print $2}' | sort | uniq -c | sort -rn | head
This is sample output - yours may be different.
history | cut -c8- | sort | uniq -c | sort -rn | head
This is sample output - yours may be different.
mysql -u root -p -N -e"show processlist\G;" | egrep "Host\:" | awk -F: '{ print $2 }' | sort | uniq -c
This is sample output - yours may be different.
mysql -u root -p -e"show processlist;"|awk '{print $3}'|awk -F":" '{print $1}'|sort|uniq -c
This is sample output - yours may be different.
4 host03.xyz.com
7 host09.xyz.com
1 localhost
3 host12.xyz.com
This command will help you to find how many number of connection are made to given mysql and what are the different hosts connected to it with number of connection they are making.
grep -R Subject /var/spool/exim/input/ | sed s/^.*Subject:\ // | sort | uniq -c | sort -n > ~/email_sort.$(date +%m.%d.%y).txt
This is sample output - yours may be different.
cat /file/way/somelogforexample | grep -o "[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}" | sort -n | uniq -c | sort -n
This is sample output - yours may be different.
curl http://www.cpan.org/modules/01modules.index.html |awk '{print $1}'|grep -v "<"|sort|uniq -c|grep -v " +[0-9] "
This is sample output - yours may be different.
Grabs the complete module list from CPAN, pulls the first column, ditches html lines, counts, ditches small namespaces.
tshark -r data.pcap -R "ip.addr==192.168.1.2 && ip.addr==64.12.24.50 && aim" -d tcp.port==443,aim -T fields -e "aim.buddyname" |sort |uniq -c
This is sample output - yours may be different.
tshark -r data.pcap -R "ip.src==192.168.1.2" -T fields -e "ip.dst" |sort |uniq -c
This is sample output - yours may be different.
dups() { sort "$@" | uniq -d; }
This is sample output - yours may be different.
netstat -tn | awk 'NR>2 {print $6}' | sort | uniq -c | sort -rn
This is sample output - yours may be different.
1618 ESTABLISHED
4 LAST_ACK
2 SYN_RECV
1 TIME_WAIT
1 CLOSE_WAIT
svn log -r{2011-08-01}:HEAD|awk '$14 ~/line/ {print $3}'|sort|uniq -c
This is sample output - yours may be different.
My script lists all users & the number of commits they made in the period, sorted alphabetically. To sort by number of commits, append a '|sort' to the end of the command. The script depends on the output format of svn log - original command didn't work for me because the string 'user' was not appearing in my output