标签:awk
从固定格式中取出IP所在的class,并列出
例:
class A {
192.168.1.1
192.168.2.1
192.168.3.1
192.168.169.69
}
class B {
192.168.1.1
192.168.169.69
}
sed -nr ‘/\{/{:1;N;/\}/!b1;/192.168.169.69/s#^([^{]+).*#\1#p}‘ file
awk -vRS=‘class *.‘ ‘/192.168.169.69/{print s}{s=RT}‘ file
sed -nr ‘/class/h;/192.168.169.69/{x;s#([^{]+).*#\1#p}‘ file
awk ‘/class/{s=$1" "$2}/192.168.169.69/{print s}‘ file
本文出自 “秋天的童话” 博客,请务必保留此出处http://wushank.blog.51cto.com/3489095/1703500
标签:awk
原文地址:http://wushank.blog.51cto.com/3489095/1703500