Results 1 to 2 of 2
i know this can be done, i just can't figure it out (i'm good with RegEx's, but bad with sed).
i need to insert file2 into file1 after finding PATTERN
...
- 08-24-2009 #1Just Joined!
- Join Date
- Aug 2006
- Location
- oklahoma
- Posts
- 12
[SOLVED] insert file after a line with sed or awk?
i know this can be done, i just can't figure it out (i'm good with RegEx's, but bad with sed).
i need to insert file2 into file1 after finding PATTERN
ex:
file1 -
abcdef
ghijklm
nopqrs
file2 -
tuvwxzy
yzxwvut
so say my pattern is "ghij". i would need to insert file2 into the line after that pattern is found.
i know this can be done with sed, the 'r' option, and somehow designating an 'a' for append, but i just don't understand the order/syntax for that.
any help would be greatly appreciated. thank you.
- 08-24-2009 #2Just Joined!
- Join Date
- Aug 2006
- Location
- oklahoma
- Posts
- 12
so i just tried a bunch of different things, and ran into the solution.
sed -i '/MYREGEXPATTERN/ r myfiletoinsert.txt' mymainfile.txt
easy enough. would be nice if you could do this with a case insensitive search, but this will do. you can just add the insensitive regex if you wanted.



