wc [OPTION]... [FILE]...
[root@senlong tmp]# wc /etc/passwd
38 50 1748 /etc/passwd
[root@senlong tmp]# wc -l /etc/passwd # 文件行数
38 /etc/passwd
[root@senlong tmp]# wc -w /etc/passwd # 文件单词数
50 /etc/passwd
[root@senlong tmp]# wc -c /etc/passwd # 文件字节数
1748 /etc/passwd
cut [OPTION]... [FILE]...
[root@senlong tmp]# cut -d: -f1 /etc/passwd # 用:切割文件,取第1个字段
[root@senlong tmp]# cut -d: -f1,7 /etc/passwd # 用:切割文件,取第1和第7个字段
[root@senlong tmp]# cut -d: -f1-3,7 --output-delimiter=' ' /etc/passwd # 用:切割文件,取第1至第3, 第7个字段,并用指定输出的分隔符
sort [OPTION]... [FILE]...
[root@senlong tmp]# sort -t: -k3 -n /etc/passwd # 以:为字段分隔符, 取第3个字段并按数值大小排序
[root@senlong tmp]# sort -t: -k3 -n /etc/passwd | cut -d: -f3 # 排序后再进行切割显示
uniq [OPTION]... [FILE]...
Note: 连续且完全相同方为重复
uniq 与 sort -u 的区别:uniq能显示每行重复的次数
[root@senlong tmp]# history | cut -d' ' -f5 | sort | uniq -c
[root@senlong tmp]# history | cut -d' ' -f5 | sort | uniq -d
[root@senlong tmp]# history | cut -d' ' -f5 | sort | uniq -u
[root@senlong tmp]# cut -d: -f6-10 /etc/passwd | sort -t: -k3 -n| cut -d: -f1