1.颠倒
[root@lxy ~]# tac /etc/passwd #上下颠倒
[root@lxy ~]# rev /etc/passwd #左右颠倒
2.统计
[root@lxy ~]# wc -l /etc/passwd #统计行数 或者-c
[root@lxy ~]# wc -w aa.txt #统计单词数
[root@lxy ~]# wc -w aa.txt #统计字符
3.排序
[root@lxy ~]# sort -n aa.txt -n 按整个数字排序
[root@lxy ~]# sort -nr aa.txt -r 降序
[root@lxy ~]# sort -nru aa.txt -u 去重
4.去重
默认连续相同行
[root@lxy ~]# sort aa.txt | uniq -c -c 求重复次数
[root@lxy ~]# sort aa.txt | uniq -d -c 只显示重复行
[root@lxy ~]# sort aa.txt | uniq -u -u 显示不重复的行
5.过滤
[root@lxy ~]# grep root /etc/passwd
[root@lxy ~]# grep -A 2 root /etc/passwd -A 匹配行后两行
[root@lxy ~]# grep -B 2 root /etc/passwd -B 匹配行前两行
[root@lxy ~]# grep -C 2 root /etc/passwd -C 前后2行
[root@lxy ~]# grep -n root /etc/passwd -n 显示行号
[root@lxy ~]# grep -i root /etc/passwd -i 忽略大小写
[root@lxy ~]# grep -v root /etc/passwd -v 取反
[root@lxy ~]# grep -x root /root/aa.txt -x 完全匹配
[root@lxy ~]# grep -rl hostname /etc/ -r 递归 -l 列出文件名
6.剪切
[root@lxy ~]# cut -d':' -f 1 /etc/passwd 第一个字段
[root@lxy ~]# cut -d':' -f 1-3 /etc/passwd 第1-3字段
[root@lxy ~]# cut -d':' -f 1,3-5 /etc/passwd 第1, 3-5字段
[root@lxy ~]# cut -c 1 /etc/passwd 取第一个字符
[root@lxy ~]# cut -c 1-10 /etc/passwd
[root@lxy ~]# cut -c 1,5-10 /etc/passwd