Thanks a lot! for providing very good solution for the Question to my earlier post - Insert content of file at specific line number of another file in LINUX/BASH. Now, I have slightly different requirement. Now I want to insert content of 'tempFile' into another file 'File1' before first occurrence of statement '@type ABCD'. I tried with following sed command
sed -n -i -e '/@type ABCD/r tempFile' -e 1x -e '2,$(x;p)' -e '$(x;p)' File1
However, the above script inserts content of tempFile in File1 multiple times as mentioned below.
File1
tempFile 01
tempFile 02
tempFile 03
tempFile 03
@type ABCDF #---Insert 'tempfile' content before First occurrence '@type ABCDF'
File2
File3
tempFile 01
tempFile 02
tempFile 03
tempFile 03
@type ABCDF
File4
tempFile 01
tempFile 02
tempFile 03
tempFile 03
@type ABCDF
File5
Please help to insert content of tempFile in File1 only before first occurance of '@type ABCD'.
Expected output
File1
tempFile 01
tempFile 02
tempFile 03
tempFile 03
@type ABCDF #---Insert 'tempfile' content before First occurrence '@type ABCDF'
File2
File3
@type ABCDF
File4
@type ABCDF
File5
Thanks in advance