-n #表明以數字方法排序,若是倒序加上-rbash
-t ':' #-t指定分隔符
-k #指定第幾列blog
----------------------------------------------------------------------排序
文本以下:class
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologintest
根據用戶ID排序grep
cat /etc/passwd|sort -t ':' -nk 3 #從小到大,以冒號爲分隔符,第三列。 cat /etc/passwd|sort -t ':' -nrk 3 #從大到小
進行/boot目錄,根據文件大小的順序輸出,從大到小的順序輸出
方法
ls -lA |grep ^- |sort -nrk 5 #-表明文件,默認以空格分隔
---------------------------------------------------------------------sort
uniq 去重 di
sort 1.txt | uniq #去重,有多行的只顯示一行 cat 1.txt |sort |uniq -c #顯示每一項重複的次數 cat 1.txt |sort |uniq -c |sort -rnk 1 #輸出行重複的次數,按重複次數從大到小的順序輸出 cat test.txt |sort |uniq -u #輸出沒有重複的行