如何从给定文件“named.conf”中提取两个字段?我想要“区域”和"file"字段。
zone "example.com" IN {
type master;
file "db.example.com";
allow-query { any; };
allow-update { none; };
allow-transfer { 10.101.100.2; };
};
最佳答案
这可能对你有用:
sed '/^\s*\(zone\|file\) "\([^"]*\)".*/,//!d;//!d;s//\2/' named.conf
example.com
db.example.com
关于正则表达式从文件中提取多行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9384787/