[英]How to find a text string within a config file and add two new lines below with one single line command?
[英]Linux command to find a specific line in file and add new lines below it
我正在尝试构建一个Linux命令来查找文件中的行并在该行下面添加更多行。 例如,在文件中搜索"Application"
,然后获取该单词所在的行,并在其下方再添加三行。 我目前正在使用绝对行号,如"sed -i '51icolumn1, column2, column3' test.txt"
但如果此文件中的内容发生了变化,我可能会将文本添加到错误的位置。
将
sed -i '/Application/a column1, column2, column3\ncolumn1, column2, column3' test.txt
解决你的问题?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.