
Terminal - Commands using sort - 527 results
awk 'BEGIN {srand()} {print int(rand()*1000000) "\t" $0}' FILE | sort -n | cut -f 2-
This is sample output - yours may be different.
Replace FILE with a filename (or - for stdin).
find -type f -printf '%P\000' | egrep -iz '\.(avi|mpg|mov|flv|wmv|asf|mpeg|m4v|divx|mp4|mkv)$' | sort -z | xargs -0 ls -1
This is sample output - yours may be different.
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"
xmms2 mlib search NOT +rating | grep -r '^[0-9]' | sed -r 's/^([0-9]+).*/\1/' | sort -R | head | xargs -L 1 xmms2 addid
This is sample output - yours may be different.
Added medialib id 5076 to playlist
Added medialib id 1537 to playlist
Added medialib id 1148 to playlist
Added medialib id 5336 to playlist
Added medialib id 3876 to playlist
Added medialib id 5165 to playlist
Added medialib id 5485 to playlist
Added medialib id 3884 to playlist
Added medialib id 498 to playlist
Added medialib id 3791 to playlist
If you're like me and want to keep all your music rated, and you use xmms2, you might like this command.
I takes 10 random songs from your xmms2 library that don't have any rating, and adds them to your current playlist. You can then rate them in another xmms2 client that supports rating (I like kuechenstation).
I'm pretty sure there's a better way to do the grep ... | sed ... part, probably with awk, but I don't know awk, so I'd welcome any suggestions.
sort -u filename > newfilename
This is sample output - yours may be different.
For users looking to simplify management of large entries in files and directories, this command is the key to fun and simplicity. Using the power sort, only a couple of seconds are necessary to accomplish what would take minutes or hours in ?standard? client applications.
find | sed -e "s/^.*\///" | awk ' BEGIN { FS=""} { print NF " " $0 } ' | sort -nrf | head -10
This is sample output - yours may be different.
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
ps aux | sort +2n | tail -20
This is sample output - yours may be different.
This command will show the 20 processes using the most CPU time (hungriest at the bottom).
You can see the 20 most memory intensive processes (hungriest at the bottom) by running:
ps aux | sort +3n | tail -20
Or, run both:
echo "CPU:" && ps aux | sort +2n | tail -20 && echo "Memory:" && ps aux | sort +3n | tail -20
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.
du -xk | sort -n | tail -20
This is sample output - yours may be different.
This command will tell you the 20 biggest directories starting from your working directory and skips directories on other filesystems. Useful for resolving disk space issues.
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
netstat -atn | awk ' /tcp/ {printf("%s\n",substr($4,index($4,":")+1,length($4) )) }' | sed -e "s/://g" | sort -rnu | awk '{array [$1] = $1} END {i=32768; again=1; while (again == 1) {if (array[i] == i) {i=i+1} else {print i; again=0}}}'
This is sample output - yours may be different.
$ netstat -atn | awk ' /tcp/ {printf("%s\n",substr($4,index($4,":")+1,length($4) )) }' | sed -e "s/://g" | sort -rnu | awk '{array [$1] = $1} END {i=32768; again=1; while (again == 1) {if (array[i] == i) {i=i+1} else {print i; again=0}}}'
32768
Some commands (such as netcat) have a port option but how can you know which ports are unused?
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.
This is sample output - yours may be different.
du -k | sort -r -n | more
This is sample output - yours may be different.
rpm -qa --qf '%{SIZE} %{NAME}\n' | sort -nr | nl | head -6 # six largest RPMs
This is sample output - yours may be different.
$ rpm -qa --qf '%{SIZE} %{NAME}\n' | sort -nr | nl | head -6 # six largest RPMs
1 783535706 ibm-notes-editors
2 396131310 ibm-notes-notesplugin
3 354961772 clipart-openclipart
4 238607804 ibm-notes-framework
5 136072442 openoffice.org-core
6 117823438 libboost-devel
Low on disk space? Check the largest installed RPMs for delete canditates.
sort file1.txt | uniq > file2.txt
This is sample output - yours may be different.
ls -l|awk '{print $6,$8}'|sort -d
This is sample output - yours may be different.
/etc$ ls -l|awk '{print $6,$8}'|sort -d
2003-12-04 locale.alias
2006-05-08 jvm
2006-07-10 mtools.conf
...
2009-03-10 resolv.conf
2009-03-11 purple
2009-03-12 gdm
Can pipe to tail or change the awk for for file size, groups, users, etc.
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.
cat $(ls -tr | tail -1) | awk '{ a[$1] += 1; } END { for(i in a) printf("%d, %s\n", a[i], i ); }' | sort -n | tail -25
This is sample output - yours may be different.
348, 192.22.16.56
358, 192.240.8.178
360, 192.107.248.220
394, 192.206.78.2
424, 192.242.141.25
426, 192.175.45.153
440, 192.51.107.202
493, 192.215.222.135
500, 192.20.53.245
688, 192.164.143.36
732, 192.139.1.20
This command is much quicker than the alternative of "sort | uniq -c | sort -n".
find . -type f -print0 | xargs -r0 stat -c %Y\ %n | sort -rn | gawk '{sub(/.\//,"",$2); print $2}' > /tmp/playlist.m3u
This is sample output - yours may be different.
Tekzilla_Daily_Tip_HD_Quicktime/Firefox_Save_Websites_As_An_Image_-_Tekzilla_Daily_Tip.mp4
MacBreak_Weekly/MacBreak_Weekly_130_I_Did_A_Fiduciary_Dooty.mp3
Buzz_Out_Loud_from_CNET/Buzz_Out_Loud_922_Hot_and_junky.mp3
The_Totally_Rad_Show_HD_Quicktime/Nash_Out_-_Halo_Wars,_Street_Fighter_The_Legend_of_Chun_Li,_Green_Hornet_and_Clue_news,_Oscar_wager_results_-_The_Totally_Rad_Show.mp4
FRAK/FRAK_0.0.5.mp4
Tekzilla_Daily_Tip_HD_Quicktime/OS_X_Perfect_Windows_Management_Expose_and_Spaces_Together_-_Tekzilla_Daily_Tip.mp4
IT_Conversations/Dion_Almaer,_Ben_Galbraith_-_Bespin.mp3
Leo_Laporte_-_The_Tech_Guy/Leo_Laporte_-_The_Tech_Guy_539.mp3
Systm_HD_Quicktime/UPS_+_Car_Battery_=_More_Computing_Or_a_48_Hour_Disco_Ball_-_Systm.mp4
Praia_das_Mas/Praia_das_Mas_3.m4a
.....
I use this to generate a playlist with all the podcasts I listen to.
Ordered from most recent to older.
du | sort -n | tail -11 | head
This is sample output - yours may be different.
The pipe to head removes the listing of . as the largest directory.
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.