grep提取含有IP的行 root@debian:~/cu# egrep -f kk /etc/passwd root@debian:~/cu# grep -E -f kk /etc/passwd
root@debian:~# ifconfig eth0|grep “[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}”
inet addr:192.168.0.4 Bcast:192.168.0.255 Mask:255.255.255.0
root@debian:~# ifconfig eth0|grep -E “([0-9]{1,3}\.){3}[0-9]”
inet addr:192.168.0.4 Bcast:192.168.0.255 Mask:255.255.255.0
禁止显示错误信息
-s, –no-messages
Suppress error messages about nonexistent or unreadable files. Portability note: unlike GNU grep, traditional
grep did not conform to POSIX.2, because traditional grep lacked a -q option and its -s option behaved like GNU
grep’s -q option. Shell scripts intended to be portable to traditional grep should avoid both -q and -s and
should redirect output to /dev/null instead.
将文件作为参数
root@debian:~/cu# cat kk
123
abc
www-data
www-data:x:33:33:www-data:/var/www:/bin/sh
www-data:x:33:33:www-data:/var/www:/bin/sh
“|” “与” “或”
输出有123或abc的行
root@debian:~# echo -e 123″\n”abc”\n”AAA|grep -E “123|AAA”
123
AAA
关键字高亮 –color
root@debian:~# echo -e 123″\n”abc”\n”AAA|grep -E “123|AAA” –color
123
AAA
我看不懂呀~~~~~
小桥,加油,上面的我也不懂……呵呵
我也不懂,我还是过来支持小桥,呵呵。
同样不懂
不懂
回复:谢谢不懂~