Using sed to insert file content

后端 未结 5 743
梦如初夏
梦如初夏 2020-11-30 07:54

I\'m trying to insert a file content before a given pattern

Here is my code:

sed -i \"\" \"/pattern/ {
i\\\\ 
r $scriptPath/adapters/default/permissi         


        
5条回答
  •  情歌与酒
    2020-11-30 08:31

    CodeGnome's solution don't work, if the pattern is on the last line.. So I used 3 commands.

    sed -i '/pattern/ i\
            INSERTION_MARKER
            ' $manifestFile
    sed -i '/INSERTION_MARKER/r $scriptPath/adapters/default/permissions.xml' $manifestFile
    sed -i 's/INSERTION_MARKER//' $manifestFile
    

提交回复
热议问题