Add Multiple Lines in an existing file

Hi Unix Experts,

I like to add the following multiple lines in an existing file:

CHANNELS:
MaxChannels=600
MaxActiveChannels=600
MaxInitiators=22

I would be highly appreciated if somebody can shed some light on it.

Thank you in advance!!!

Khan

Use VI editor to do so. Open the existing file in vi editor and then press the key escape + i. copy those lines and pest it in the required location.

Thank you for your simple solution but probably I missed in my question. Let me put it this way, How can I add multiple lines in an existing file using a script. NOT MANUALLY!!!

I hope you understand my question.

Thank you for all who can shed some light!!!

Khan

Have you any experience in shell scripting?
Anyway, to add those lines to files, you can use cat and the >>

cat existing_file >> some_file

provided your existing_file contains only the lines you want to add.

echo "MaxChannels=600
MaxActiveChannels=600
MaxInitiators=22" >> file_name

Just give your file name after redirection operator.

If you want to add those lines in any part of file then u can do that by using SED

"sedscript" file
############
/pattern/a\
CHANNELS:\
MaxChannels=600\
MaxActiveChannels=600\
MaxInitiators=22
############

sed -f sedscript ipfile

If you want to insert after for example 10th line then use
10a\

If you want to insert before that pattern or some line then use
10i\