1

I was wondering how to print the contents of a file above the occurrence of a pattern in another file. I know that using sed -n '/^PATTERN/i\\ INSERTING' filename would insert above the pattern but can i display the contents of a file instead? This command got close sed '/^Stephen/r siid' addrfile but i want the file to be displayed before the occurrence of the pattern

1 Answers1

0
sed -e '/PATTERN/r file' -e '$!N;P;D'

Doesn't work for PATTERN on the last line.

With GNU sed:

sed '/PATTERN/e cat file'