简体   繁体   English

在bash中的行号上插入文本后面的文本

[英]insert a text after text on line number in bash

I'm trying to add a master dns ip address in the named.conf file located on line 11. The text on this line is: 我正在尝试在第11行的named.conf文件中添加一个主dns ip地址。这一行的文字是:

listen-on port 53 {127.0.0.1; }

I want to add the ipaddress after; 我想在之后添加ipaddress; to make: 制作:

listen-on port 53 {127.0.0.1; ipaddress; }

How would i do such a thing with sed or awk on line 11? 我如何用11号线上的sed或awk做这样的事情?

You can use this sed , 你可以用这个sed

sed '11s/}[ ]*$/ip_address;}/' named.conf

To do the in-place edit: 要进行就地编辑:

sed -i '11s/}[ ]*$/ip_address}/' named.conf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM