从固定格式中取出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
时间: 2024-07-28 19:31:00