1、grep命令 -i ##忽略大小写 -n ##显示结果所在行的行号 -c ##结果个数 -v ##反向过滤 -r 关键字 目录 ##在目录中过滤含有关键字的文件 -E “关键字1|关键字2|…” ##过滤多个关键字
[root@localhost ~]# cp /etc/passwd . [root@localhost ~]# ls file filegreat file.new file.orig passwd [root@localhost ~]# echo “ROOT” >>passwd [root@localhost ~]# grep root passwd root:x:0:0:root:/root:/bin/bash operator:x:11:0:operator:/root:/sbin/nologin [root@localhost ~]# grep -n root passwd 1:root:x:0:0:root:/root:/bin/bash 10:operator:x:11:0:operator:/root:/sbin/nologin [root@localhost ~]#grep -in root passwd 1:root:x:0:0:root:/root:/bin/bash 10:operator:x:11:0:operator:/root:/sbin/nologin 41:ROOT [root@localhost ~]# grep -iv root passwd
[root@localhost ~]# grep -ic root passwd
3、sort -n ##纯数字排序 -r ##倒序 -u ##去掉重复行 -t ##指定分隔符 -k ##指定排序的列
4、uniq ##处理重复行 -c ##统计重复行行数 -u ##显示唯一的行 -d ##显示重复行
5、tr tr ‘A-Z’ ‘a-z’