Insert content of a file after a certain line in another file

Hi, it's my first post to this forum. I just started bash and I'm stuck at one issue. I want to include content of a file in another file after a certain line. I'm using sed for inserting one line but how to insert all content of a file ?

For example i have a file list.txt with a few lines and another file list2.txt. i want to include content of list.txt in list2.txt after "sample" string.

Thanks.

Ty...

 
sed '/sample/r list.txt' list2.txt

Welcome to the forum ! :slight_smile:

Let me hint you with this,

scan through the each line in the file1
compare it with the compare string
if match
cat the second file
else <dont match>
print the current word
fi

Thank you both.
malcomex999 it worked fine but how to insert list before word "sample" ?
It's not that i don't want to search and try but I didn't find any reference about this, maybe you can point me in the right direction, a good sed tutorial

check this link, i hope it helps...

Sed - An Introduction and Tutorial