
Terminal - Commands using sort - 527 results
netstat -tn | grep :80 | awk '{print $5}'| grep -v ':80' | cut -f1 -d: |cut -f1,2,3 -d. | sort | uniq -c| sort -n
This is sample output - yours may be different.
1 192.168.1.5
5 192.168.1.2
8 192.168.1.52
15 192.168.1.3
19 192.168.1.30
cut -f1,2 - IP range 16
cut -f1,2,3 - IP range 24
cut -f1,2,3,4 - IP range 24
nl -ba FILE | sort -nr | cut -f2-
This is sample output - yours may be different.
"nl -ba" numbers all lines in the file (including empty lines), "sort -nr"
sorts the lines in descending order, and the "cut" command finally removes
the line numbers again.
find . -type f -exec stat -f '%m %N' {} \; | sort -n
This is sample output - yours may be different.
here's a version which works on OS X.
This is sample output - yours may be different.
expac -S -H M "%m %n"|sort -n
This is sample output - yours may be different.
M is size in megabytes, man expac to see other sizes
%m is install size
%k is download size
rpm -qa | sort | sed -n -e "s/\-[0-9].[0-9]*.*//p" | uniq
This is sample output - yours may be different.
[root@cc05 ~]# rpm -qa | sort | sed -n -e "s/\-[0-9].[0-9]*.*//p" | uniq
acl
acpid
alchemist
alsa-lib
alsa-utils
amtu
anacron
apr
apr-util
aspell
aspell-en
at
atk
at-spi
attr
audiofile
audit
audit-libs
audit-libs-python
authconfig
authconfig-gtk
autoconf
autofs
automake14
automake15
automake16
automake17
automake
This will list all installed packages on a RedHat/CentOS based system, sort them alphabetically, Parse off the version numbers, and delete any duplicate entries.
This is good if you need to build out a mirrored system or rebuild a failing system.
git ls-files | xargs -n1 git blame --line-porcelain | sed -n 's/^author //p' | sort -f | uniq -ic | sort -nr
This is sample output - yours may be different.
Uses line-porcelain in git blame, which makes it easier to parse the output.
cp $(find /media/ -type f -name "*.wav" -printf "%T@ %h/%f\n" | sort | tail -1 | awk '{ print $2 }') .
This is sample output - yours may be different.
Watch out if you have several USB drives plugged in: it scans the whole /media/ folder !!! You can replace /media/ by the path of a specific USB drive (something like /media/F77A-530B/)
I use a sound recorder and I want to plug the recorder and grab the most recent sound.
That's what this command does.
Use mv instead of cp to move instead of copy.
Change *.wav to the required file type.
mysqlbinlog <logfiles> | grep exec | grep end_log_pos | grep -v exec_time=0 | sed 's/^\(.*exec_time=\([0-9]\+\).*\)/\2 - \1 /' | sort -n
This is sample output - yours may be different.
...
1 - #120528 21:55:39 server id 1 end_log_pos 10474343 Query thread_id=2446084 exec_time=1 error_code=0
15 - #120528 21:55:17 server id 1 end_log_pos 10473569 Query thread_id=2446071 exec_time=15 error_code=0
22 - #120528 21:55:17 server id 1 end_log_pos 10474905 Query thread_id=2446084 exec_time=22 error_code=0
...
Shows sorted by query time, the headers of mysqlbinlog entries. Then is easy to locate the heavier events on the raw log dump
find /proc/sys/vm -maxdepth 1 -type f | while read i ; do printf "%-35s\t%s\n" "$i" "$(<$i)" ; done | sort -t/ -k4
This is sample output - yours may be different.
/proc/sys/vm/block_dump 0
/proc/sys/vm/dirty_background_bytes 0
/proc/sys/vm/dirty_background_ratio 5
/proc/sys/vm/dirty_bytes 0
/proc/sys/vm/dirty_expire_centisecs 3000
/proc/sys/vm/dirty_ratio 10
/proc/sys/vm/dirty_writeback_centisecs 500
/proc/sys/vm/drop_caches 0
/proc/sys/vm/hugepages_treat_as_movable 0
/proc/sys/vm/hugetlb_shm_group 0
/proc/sys/vm/laptop_mode 0
/proc/sys/vm/legacy_va_layout 0
/proc/sys/vm/lowmem_reserve_ratio 256 256 32
/proc/sys/vm/max_map_count 65530
... snip ...
Sometimes you want to see all of the systcls for a given $thing. I happened to need to easily look at all of the vm sysctls between two boxes and compare them. This is what I came up with.
lsof +c 15 | awk '{print $1}' | sort | uniq -c | sort -rn | head
This is sample output - yours may be different.
5993 chromium-browse
1466 gwibber-service
1148 xfce4-terminal
765 bash
725 ssh
721 apache2
314 pidgin
298 thunderbird-bin
295 gtk-window-deco
288 firefox
ls -l| sort +4n|tail -1| awk '{print $NF}'
This is sample output - yours may be different.
find . -printf "%s %p\n" | sort -n
This is sample output - yours may be different.
This doesn't require any non-standard programs.
find . -ls | sort -k 7 -n
This is sample output - yours may be different.
50879336 0 -rw-r--r-- 1 d332027 staff 0 13 May 2010 ./android-sdk-mac_86/docs/assets-sdk/placeholder
50883450 0 -rw-r--r-- 1 d332027 staff 0 13 May 2010 ./android-sdk-mac_86/docs/googleb38c1d60b7ba5d19.html
50885421 0 -rw-r--r-- 1 d332027 staff 0 13 May 2010 ./android-sdk-mac_86/platforms/android-7/data/service_actions.txt
...
73811131 1527672 -rw-r--r-- 1 d332027 staff 782166182 16 Mar 16:58 ./PlaneShift-v0.5.8.exe
73799979 1806344 -rw-r--r-- 1 d332027 staff 924846080 16 Mar 12:34 ./PlaneShift-v0.5.8.dmg
for those without the tree command.
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
tree -ifs --noreport .|sort -n -k2
This is sample output - yours may be different.
or
tree -ifsF --noreport .|sort -n -k2|grep -v '/$'
(rows presenting directory names become hidden)
atq |sort -k 6n -k 3M -k 4n -k 5 -k 7 -k 1
This is sample output - yours may be different.
3674 Fri May 4 08:11:00 2012 m master
3669 Fri May 4 08:31:00 2012 t master
3664 Fri May 4 08:48:00 2012 s master
3626 Fri May 4 16:27:00 2012 S master
3634 Fri May 4 18:09:00 2012 S master
3636 Fri May 4 18:19:00 2012 S master
3639 Fri May 4 18:24:00 2012 S master
3649 Fri May 4 20:39:00 2012 S master
3718 Sat May 5 15:48:00 2012 S master
3720 Sat May 5 18:00:00 2012 S master
3724 Sat May 5 18:25:00 2012 S master
3727 Sat May 5 18:25:00 2012 S master
3728 Sat May 5 18:37:00 2012 S master
3742 Sat May 5 22:26:00 2012 S master
3786 Sun May 6 15:32:00 2012 S master
3788 Sun May 6 15:32:00 2012 S master
3790 Sun May 6 15:33:00 2012 S master
3792 Sun May 6 15:33:00 2012 S master
3796 Sun May 6 16:09:00 2012 S master
3655 Mon May 7 07:04:00 2012 s master
3670 Mon May 7 08:11:00 2012 m master
couldn't stand previous unsortability of at jobs list
ls -l | sort +4n for ascending order or ls -l | sort +4nr for descending order
This is sample output - yours may be different.
compgen -c | sort -u > commands && less commands
This is sample output - yours may be different.
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
for k in $(git branch | sed /\*/d); do echo "$(git log -1 --pretty=format:"%ct" $k) $k"; done | sort -r | awk '{print $2}'
This is sample output - yours may be different.
master
testing
this-shit-works
Simpler and without all of the coloring gimmicks. This just returns a list of branches with the most recent first. This should be useful for cleaning your remotes.
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.
for a in $(< FILENAME); do echo "$(bc <<< $(wc -m<<<$a)-1) $a";done|sort -n
This is sample output - yours may be different.