6月11号 晚上8点半
提取字段用:awk 与cut 如提取passwd中第五个字段。
6月12号 下午2点
正则表达式,IP地址的匹配:使用grep的时候不太支持正则表达式,需要转义字符\匹配使用
[root@fsailing1 shell]# cat chen3.txt 192.168.110.1 10.5.110.238 192.184.110.112 1110.333.44.1111 [root@fsailing1 shell]# cat chen3.txt|egrep '([0-9]\{1,3\}\.)\{1,3\}([0-9])\{1,3\}' [root@fsailing1 shell]# cat chen3.txt|grep '([0-9]\{1,3\}\.)\{1,3\}([0-9])\{1,3\}' [root@fsailing1 shell]# cat chen3.txt|grep '\([0-9]\{1,3\}\.\)\{1,3\}\([0-9]\)\{1,3\}' 192.168.110.1 10.5.110.238 192.184.110.112 1110.333.44.1111 如果使用egrep就不同了,它是grep里面专门用来匹配正则表达式的。
[root@fsailing1 shell]# cat chen3.txt|egrep '([0-9]\.{1,3}){1,3}([0-9]){1,3}' 192.168.110.1 10.5.110.238 192.184.110.112 1110.333.44.1111