shell三剑客
shell三剑客
=grep==
grep 的全程为Global search Regular Expression and Print out the line (类似windows 平台的ctrl+F)
#过滤出/etc/passwd 包含root的行
cat /etc/passwd|grep root
#不区分大小写搜索root行:-i
grep -i root /tmp/passwd
#显示搜索结果的行号:-n
grep -n root /tmp/passwd
#统计搜索到root的行数,计数:-c
grep -c root /tmp/passwd
#精确匹配root行:-w
cat /tmp/passwd |grep -w root
#搜索包含root和mail的行: egrep|grep -E
cat /etc/passwd | grep -e root -e mail
cat /etc/passwd | egrep “root|mail”
cat /etc/passwd | grep -E “root|mail”
#屏蔽标准输出:-q