Using sed to insert file content

后端 未结 5 746
梦如初夏
梦如初夏 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:47

    Just remove i\\.

    Example:

    $ cat 1.txt
    abc
    pattern
    def
    
    $ echo hello > 2.txt
    
    $ sed -i '/pattern/r 2.txt' 1.txt
    
    $ cat 1.txt
    abc
    pattern
    hello
    def
    

提交回复
热议问题