Reputation: 11
I was able to extract these lines from a text file
TBL Papers
Papers_ShortName "TPJ341861"
Papers_Name "BANK 240314 341861 "
MMInstrumentType P "Discounted Paper"
but wanted to insert a new line( text before the match TBL Papers). see expected output
ACTION "INS"
TBL Papers
Papers_ShortName "TPJ341861"
Papers_Name "BANK 240314 341861 "
MMInstrumentType P "Discounted Paper"
How do I do that ? thanks
Upvotes: 0
Views: 93
Reputation: 41446
Using awk
awk '/TBL Papers/ {$0="ACTION \"INS\"" RS$0}8' file
ACTION "INS"
TBL Papers
Papers_ShortName "TPJ341861"
Papers_Name "BANK 240314 341861 "
MMInstrumentType P "Discounted Paper"
This code will add a line above pattern TBL Papers
and then print everything out.
Upvotes: 1