Inserting multiline text from file to another file after pattern

前端 未结 2 1965
太阳男子
太阳男子 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"

提交回复
热议问题