
Terminal - Commands using uniq - 172 results
netstat -lantp | grep -i establ | awk -F/ '{print $2}' | uniq | sort
This is sample output - yours may be different.
java
pidgin
pidgin
pidgin
pidgin
pidgin
thunderbird-b
thunderbird-b
thunderbird-b
thunderbird-b
Can be used to discover what programms create internet traffic. Skip the part after awk to get more details.
Has anyone an idea why the uniq doesn't work propperly here (see sample output)?
awk '{print $1}' /var/log/httpd/access_log | sort | uniq -c | sort -rnk1 | head -n 10
This is sample output - yours may be different.
find -type f -exec md5sum '{}' ';' | sort | uniq --all-repeated=separate -w 33 | cut -c 35-
This is sample output - yours may be different.
Calculates md5 sum of files. sort (required for uniq to work). uniq based on only the hash. use cut ro remove the hash from the result.
netstat -ant | grep :80 | grep ESTABLISHED | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | sort -n
This is sample output - yours may be different.
1 200.79.138.35
1 201.145.29.126
2 189.135.132.228
The command could show you all conecctions if you skip "grep ESTABLISHED"
svn ls -R | egrep -v -e "\/$" | xargs svn blame | awk '{print $2}' | sort | uniq -c | sort -r
This is sample output - yours may be different.
2038 askedrelic
433 john
263 ryan
186 alice
167 bob
I'm working in a group project currently and annoyed at the lack of output by my teammates. Wanting hard metrics of how awesome I am and how awesome they aren't, I wrote this command up.
It will print a full repository listing of all files, remove the directories which confuse blame, run svn blame on each individual file, and tally the resulting line counts. It seems quite slow, depending on your repository location, because blame must hit the server for each individual file. You can remove the -R on the first part to print out the tallies for just the current directory.
DD=`cat /etc/my.cnf | sed "s/#.*//g;" | grep datadir | tr '=' ' ' | gawk '{print $2;}'` && ( cd $DD ; find . -mindepth 2 | grep -v db\.opt | sed 's/\.\///g; s/\....$//g; s/\//./;' | sort | uniq | tr '/' '.' | gawk '{print "CHECK TABLE","`"$1"`",";";}' )
This is sample output - yours may be different.
CHECK TABLE `mysql.columns_priv` ;
CHECK TABLE `mysql.db` ;
CHECK TABLE `mysql.func` ;
CHECK TABLE `mysql.help_category` ;
CHECK TABLE `mysql.help_keyword` ;
CHECK TABLE `mysql.help_relation` ;
CHECK TABLE `mysql.help_topic` ;
CHECK TABLE `mysql.host` ;
CHECK TABLE `mysql.tables_priv` ;
CHECK TABLE `mysql.time_zone` ;
CHECK TABLE `mysql.time_zone_leap_second` ;
CHECK TABLE `mysql.time_zone_name` ;
CHECK TABLE `mysql.time_zone_transition` ;
CHECK TABLE `mysql.time_zone_transition_type` ;
CHECK TABLE `mysql.user` ;
CHECK TABLE `mysql.user_info` ;
This command will generate "CHECK TABLE `db_name.table_name` ;" statements for all tables present in databases on a MySQL server, which can be piped into the mysql command. (Can also be altered to perform OPTIMIZE and REPAIR functions.)
Tested on MySQL 4.x and 5.x systems in a Linux environment under bash.
cat /var/log/secure.log | awk '{print substr($0,0,12)}' | uniq -c | sort -nr | awk '{printf("\n%s ",$0) ; for (i = 0; i<$1 ; i++) {printf("*")};}'
This is sample output - yours may be different.
-macbook:~ root# cat /var/log/secure.log | awk '{print substr($0,0,12)}' | uniq -c | sort -nr | awk '{printf("\n%s ",$0) ; for (i = 0; i<$1 ; i++) {printf("*")};}' | head
9 Jul 21 20:21 *********
9 Jul 20 19:46 *********
9 Jul 20 14:46 *********
7 Jul 23 16:55 *******
6 Jul 22 21:01 ******
6 Jul 20 21:05 ******
5 Jul 22 21:02 *****
4 Jul 20 21:25 ****
4 Jul 20 21:12 ****
Busiest seconds:
cat /var/log/secure.log | awk '{print substr($0,0,15)}' | uniq -c | sort -nr | awk '{printf("\n%s ",$0) ; for (i = 0; i<$1 ; i++) {printf("*")};}'
lsof |awk ' {if ( $0 ~ /home/) print substr($0, index($0,"/home") ) }'|cut -d / -f 1-4|sort|uniq -c|sort -bgr
This is sample output - yours may be different.
egrep -r '(render_message|multipart).*('`find app/views -name '*.erb' | grep mailer | sed -e 's/\..*//' -e 's/.*\///' | uniq | xargs | sed 's/ /|/g'`')' app/models
This is sample output - yours may be different.
awk -F\" '{print $4}' *.log | grep -v "eviljaymz\|\-" | sort | uniq -c | awk -F\ '{ if($1>500) print $1,$2;}' | sort -n
This is sample output - yours may be different.
jaymz@bowser:~/Desktop/tmp$ awk -F\" '{print $4}' *.log | grep -v "eviljaymz\|\-" | sort | uniq -c | awk -F\ '{ if($1>500) print $1,$2;}' | sort -n
517 http://kyberia.sk/id/63756
621 http://kyberia.sk/id/15
628 http://bdelive.fr/shoutbox_view.php?0?auto_refresh=1
644 http://digg.com/all/upcoming/most
658 http://winkftp.free.fr/minichat/minichatone.php
690 http://loading.se/forum.php?thread_id=125&page=412
704 http://www.reddit.com/new/
715 http://www.okoun.cz/boards/komixove_stripy
726 http://www.skyscrapercity.com/showthread.php?t=521993&page=343
759 http://www.reddit.com/r/programming/comments/7zena/reasons_why_people_who_work_with_computers_seem/
760 http://www.kalerab.sk/forum.php?forumid=1243
787 http://www.graphilla.com/viewtopic.php?t=15983&start=1000
819 http://www.google.com/reader/view/
878 http://www.reddit.com/?count=25&after=t3_7z5oj
884 http://www.diskusjon.no/index.php?showtopic=690294&st=8680
998 http://www.reddit.com/top/
1151 http://www.imilovice.cz/main/forum.php?action=showthread&threadid=20192
1239 http://www.ziapps.com/
1259 http://www.jimmyr.com/
1369 http://www.nyx.cz/index.php?l=topic;id=64
1381 http://www.stumbleupon.com/toolbar/
2559 http://twitturls.com/
2763 http://www.reddit.com/
2897 http://www.waarmaarraar.nl/opmerkelijkbeeld/0/GO/0/opmerkelijke_beelden.html
2994 http://www.reddit.com/r/pics/
4445 http://www.reddit.com/r/programming/
8222 http://www.bdelive.fr/shoutbox_view.php?0?auto_refresh=1
24220 http://www.plurk.com/getWidget?uid=423872&h=375&w=190&u_info=1&bg=cf682f&tl=cae7fd
This prints a summary of your referers from your logs as long as they occurred a certain number of times (in this case 500). The grep command excludes the terms, I add this in to remove results Im not interested in.
wget -q -O- http://www.gutenberg.org/dirs/etext96/cprfd10.txt | sed '1,419d' | tr "\n" " " | tr " " "\n" | perl -lpe 's/\W//g;$_=lc($_)' | grep "^[a-z]" | awk 'length > 1' | sort | uniq -c | awk '{print $2"\t"$1}'
This is sample output - yours may be different.
aback 1
abandon 6
abandoned 13
abase 1
abased 1
abashed 7
abated 1
abatement 1
...
This command might not be useful for most of us, I just wanted to share it to show power of command line.
Download simple text version of novel David Copperfield from Poject Gutenberg and then generate a single column of words after which occurences of each word is counted by sort | uniq -c combination.
This command removes numbers and single characters from count. I'm sure you can write a shorter version.
netstat -an | grep ESTABLISHED | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | awk '{ printf("%s\t%s\t",$2,$1) ; for (i = 0; i < $1; i++) {printf("*")}; print "" }'
This is sample output - yours may be different.
64.74.153.141 3 ***
192.168.10.10 5 *****
Written for linux, the real example is how to produce ascii text graphs based on a numeric value (anything where uniq -c is useful is a good candidate).
emerge -epv world | grep USE | cut -d '"' -f 2 | sed 's/ /\n/g' | sed '/[(,)]/d' | sed s/'*'//g | sort | uniq > use && grep ^- use | sed s/^-// | sed ':a;N;$!ba;s/\n/ /g' > notuse && sed -i /^-/d use && sed -i ':a;N;$!ba;s/\n/ /g' use
This is sample output - yours may be different.
This command puts all the flags of the USE variable actually used by the packages you emerged to the file "use", and those which are unused but available to the file "notuse"
grep -r "mystring" . |uniq | cut -d: -f1 | xargs sed -i "s/mystring//"
This is sample output - yours may be different.
Linux : these script enable you to edit multiple files and remove exact phrase from multiple files
history|awk '{print $2}'|awk 'BEGIN {FS="|"} {print $1}'|sort|uniq -c|sort -r
This is sample output - yours may be different.
8 wine
8 kill
7 killall
66 cd
5 wget
4 telnet
It will return a ranked list of your most commonly-entered commands using your command history
cat /var/log/secure | grep smtp | awk '{print $9}' | cut -f2 -d= | sort | uniq -c | sort -n | tail
This is sample output - yours may be different.
Searches /var/log/secure for smtp connections then lists these by number of connections made and hosts.
cat /var/log/secure | grep sshd | grep Failed | sed 's/invalid//' | sed 's/user//' | awk '{print $11}' | sort | uniq -c | sort -n
This is sample output - yours may be different.
2 67.11.200.144
4 210.40.128.31
6 208.71.128.195
6 64.39.0.38
15 219.246.112.241
20 200.214.15.142
30 119.70.154.57
30 79.38.22.92
40 61.152.201.74
87 88.191.94.168
107 200.27.214.30
107 61.134.27.234
115 200.6.208.186
170 222.73.37.25
387 99.154.226.153
548 222.35.78.224
627 94.75.240.141
946 213.191.111.5
Searches the /var/log/secure log file for Failed and/or invalid user log in attempts.
netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
This is sample output - yours may be different.
20 81.49.60.x
21 116.212.111.x
26 65.184.224.x
31 189.61.36.x
84 89.180.3.x
212 127.0.0.1
Here is a command line to run on your server if you think your server is under attack. It prints our a list of open connections to your server and sorts them by amount.
BSD Version:
netstat -na |awk '{print $5}' |cut -d "." -f1,2,3,4 |sort |uniq -c |sort -nr
cat file.txt | sort | uniq -dc
This is sample output - yours may be different.
Displays the duplicated lines in a file and their occuring frequency.
sort file1.txt | uniq > file2.txt
This is sample output - yours may be different.
grep Mar/2009 /var/log/apache2/access.log | awk '{ print $1 }' | sort -n | uniq -c | sort -rn | head
This is sample output - yours may be different.
zgrep "Failed password" /var/log/auth.log* | awk '{print $9}' | sort | uniq -c | sort -nr | less
This is sample output - yours may be different.
3478 invalid
1255 root
11 mysql
8 mail
6 www-data
This command checks for the number of times when someone has tried to login to your server and failed. If there are a lot, then that user is being targeted on your system and you might want to make sure that user either has remote logins disabled, or has a strong password, or both. If your output has an "invalid" line, it is a summary of all logins from users that don't exist on your system.
gunzip -c /var/log/auth.log.*.gz | cat - /var/log/auth.log /var/log/auth.log.0 | grep "Invalid user" | awk '{print $8;}' | sort | uniq -c | less
This is sample output - yours may be different.
cat file1.txt | uniq > file2.txt
This is sample output - yours may be different.
find . -type f -name "*.java" -print0 | xargs -0 -n 1 svn blame | sed -n 's/^[^a-z]*\([a-z]*\).*$/\1/p' | sort | uniq -c | sort -n
This is sample output - yours may be different.