wc命令:word count(單詞統(tǒng)計(jì)命令)
synopsis
wc [option]....[FILE]
options
-
-l: 只顯示行數(shù)
[root@localhost qibin]# wc -l /etc/fstab 15 /etc/fstab
-
-w: 只顯示單詞數(shù)
[root@localhost qibin]# wc -c /etc/fstab 805 /etc/fstab
cut命令:切割文本文件(以指定的字符進(jìn)行分割)
synopsis
cut [option]....[FILE]
options
-d DELIMITER: 指名分割符
-
-f FILEDS: 知名要顯示的字段
[root@localhost qibin]# cat /etc/passwd | cut -d : -f 1,2,3,4,5 root:x:0:0:root bin:x:1:1:bin daemon:x:2:2:daemon adm:x:3:4:adm lp:x:4:7:lp sync:x:5:0:sync FILEDS 可以是不連續(xù)的如1,3,4 也可以是連續(xù)的例如1-3,7
-
--output-delimiter=String: 指名輸出的分割符
[root@localhost qibin]# cat /etc/passwd | cut -d : --output-delimiter=" " -f 1,2,3,4,5 root x 0 0 root bin x 1 1 bin daemon x 2 2 daemon adm x 3 4 adm lp x 4 7 lp sync x 5 0 sync
sort命令:排序命令
synopsis
sort [option]...[FILE]....
options
-f: 忽略字符大小寫
-r: 逆序排列
-t DELIMITER: 字段分割符
-
-k #: 以指定字段進(jìn)行排序
[root@localhost qibin]# cat /etc/passwd | sort -t : -k 2 root:x:0:0:root:/root:/bin/bash uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin operator:x:11:0:operator:/root:/sbin/nologin usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin bin:x:1:1:bin:/bin:/sbin/nologin games:x:12:100:games:/usr/games:/sbin/nologin gopher:x:13:30:gopher:/var/gopher:/sbin/nologin
-u :去重顯示
uniq命令:去重顯示(連續(xù)且相同才叫重復(fù))
synopsis
uniq [option]...[FILE]...
options
-
-c: 顯示每行重復(fù)出現(xiàn)的次數(shù)
[root@localhost qibin]# history | cut -d" " -f 5 | sort | uniq -c 12 cat 5 clear 16 history 2 ifconfig 6 ls 4 man 1 rm 1 sort 1 sout 2 tail 1 tty 1 uniq 1 unique 3 vim 5 wc 2 who 1 whoami
-
-d: 僅顯示重復(fù)過(guò)的行
[root@localhost qibin]# history | cut -d" " -f 5 | sort | uniq -d cat clear history ifconfig ls man tail vim wc who
-
-u: 僅顯示不曾出現(xiàn)過(guò)的行
[root@localhost qibin]# history | cut -d" " -f 5 | sort | uniq -u 1 2 3 4 5 6 7 8 9 rm sort sout tty uniq unique whoami