我需要一些 sed 替换方面的帮助:
sed -ri 's#logging {
/* If you want to enable debugging, eg. using the 'rndc trace' command,
* named will try to write the 'named.run' file in the $directory (/var/named").
* By default, SELinux policy does not allow named to modify the /var/named" directory,
* so put the default debug log file in data/ :
*/
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
#logging {
/* If you want to enable debugging, eg. using the 'rndc trace' command,
* named will try to write the 'named.run' file in the $directory (/var/named").
* By default, SELinux policy does not allow named to modify the /var/named" directory,
* so put the default debug log file in data/ :
*/
channel default_debug {
file "data/named.run";
severity dynamic;
};
category security { null; };
};
#g' /etc/named.conf
基本上,我试图在很多系统上将“category security { null; };”添加到 /etc/named.conf(不同服务器上的行号不同),但 sed 失败了。
非常感谢您的任何提示和建议。
答案1
创建一个文件并输入此
/severity dynamic;/ {
N
s/\( *};\)/\1\ncategory security {null;};/g
}
然后保存并像这样运行
sed -f file /etc/named.conf