grep主要用于文本匹配
-i 不区分大小写
-n显示行数
-v 不包含
-c 统计行数
eg:
[root@localhost sjdtest]# ifconfig |grep -i "INET"
inet addr:172.17.42.1 Bcast:0.0.0.0 Mask:255.255.0.0
inet6 addr: fe80::d4ff:ebff:fe3f:3cf0/64 Scope:Link
inet addr:192.168.2.14 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe92:a8ec/64 Scope:Link
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host