I have file1 & file2, I want to cat
file1 into file2 after match of 22
pattern.
Can I do it with cat
or I need to go for awk
or sed
file1
aa
bb
cc
file2
11
22
33
44
Resultant file2
11
22
aa
bb
cc
33
44
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityI have file1 & file2, I want to cat
file1 into file2 after match of 22
pattern.
Can I do it with cat
or I need to go for awk
or sed
aa
bb
cc
11
22
33
44
11
22
aa
bb
cc
33
44
For completeness, here is an awk solution:
$ awk '{print;} /22/{system("cat file1");}' file2
11
22
aa
bb
cc
33
44