Inserting multiline text from file to another file after pattern

前端 未结 2 1942
太阳男子
太阳男子 2021-01-13 10:55

I have files like:

text2insert
filewithpattern

and also known:

pattern

How

相关标签:
2条回答
  • 2021-01-13 11:36
    awk 'FNR==NR{      a[c++]=$0;next     }
    /pattern1/{g=1;next}
    /pattern2/{g=0;next}
    g{ 
      for(i=1;i<=c;i++){
        print a[i]
      }
    }' text2insert filewithpattern
    

    And why do you need "garbage" in your output? Your previous question seems not to include "garbage"

    0 讨论(0)
  • 2021-01-13 11:37
    sed -e '/pattern/r text2insert' filewithpattern
    
    0 讨论(0)
提交回复
热议问题