Insert a line at specific line number with sed or awk

后端 未结 9 1470
佛祖请我去吃肉
佛祖请我去吃肉 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:35

    An ed answer

    ed file << END
    8i
    Project_Name=sowstest
    .
    w
    q
    END
    

    . on its own line ends input mode; w writes; q quits. GNU ed has a wq command to save and quit, but old ed's don't.

    Further reading: https://gnu.org/software/ed/manual/ed_manual.html

提交回复
热议问题