Insert a line at specific line number with sed or awk

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

    OS X / macOS / FreeBSD sed

    The -i flag works differently on macOS sed than in GNU sed.

    Here's the way to use it on macOS / OS X:

    sed -i '' '8i\
    8 This is Line 8' FILE
    

    See man 1 sed for more info.

提交回复
热议问题