将在特定的行号与行awk或者sed [英] Insert a line at specific line number with sed or awk
本文介绍了将在特定的行号与行awk或者sed的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有我需要另一个脚本修改插入在8号线的文本脚本文件。
要插入的字符串: PROJECT_NAME = sowstest
,进入一个名为启动
我试着用awk和sed,但我的命令是越来越乱码。
解决方案
SED -i8i8这是8号线FILE
在第8行插入
8这是8号线
到文件文件
-i
做的修改直接file文件,没有输出到stdout,如由格伦·杰克曼的评论中提到。
I have a script file which I need to modify with another script to insert a text at the 8th line.
String to insert: Project_Name=sowstest
, into a file called start
.
I tried to use awk and sed, but my command is getting garbled.
解决方案
sed -i '8i8 This is Line 8' FILE
inserts at line 8
8 This is Line 8
into file FILE
-i
does the modification directly to file FILE, no output to stdout, as mentioned in the comments by glenn jackman.
这篇关于将在特定的行号与行awk或者sed的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文