Insert a line at specific line number with sed or awk

后端 未结 9 1475
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-30 17:15

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 c

9条回答
  •  醉话见心
    2020-11-30 17:40

    For those who are on SunOS which is non-GNU, the following code will help:

    sed '1i\^J
    line to add' test.dat > tmp.dat
    
    • ^J is inserted with ^V+^J
    • Add the newline after '1i.
    • \ MUST be the last character of the line.
    • The second part of the command must be in a second line.

提交回复
热议问题