appending lines to a file dynamically

Hi all,
I have a file with some number of lines. I need to add certain number of lines from another file which may vary according to the user's input and to it.

eg
code:
I/P
file 1
apps/file/xyz
apps/file/abc
apps/file/def
file 2
progs/file/xyz
apps/file/xyz
load \ file1
load \file2
O/P
apps/file/xyz
apps/file/abc
apps/file/def
load \ file1
load \file2

I need to append the lines which start only with load which will vary according to the user's input.

Is there any way to do it??

Thanks in advance
Ananth

perl -ne 'open F,">>file1";/^load/&&print F "$_";close F' file2

Thanks :slight_smile: