The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
insert multiple lines into a file c0mrade Shell Programming and Scripting 12 09-04-2008 04:04 PM
put the contents of this file into a variable with multiple lines Nomaad Shell Programming and Scripting 3 04-23-2008 12:39 AM
retrieved multiple lines on multiple places in a file dala Shell Programming and Scripting 8 03-14-2008 03:28 PM
How to copy multiple lines from a file to another using AWK? jisha Shell Programming and Scripting 3 01-08-2008 01:04 AM
Need to delete multiple lines in a file. kangdom Shell Programming and Scripting 6 10-16-2006 11:02 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-04-2006
hkhan12 hkhan12 is offline
Registered User
  
 

Join Date: Jan 2005
Location: Canada
Posts: 9
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
  #2 (permalink)  
Old 09-05-2006
Balkrishna Balkrishna is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 5
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.
  #3 (permalink)  
Old 09-05-2006
hkhan12 hkhan12 is offline
Registered User
  
 

Join Date: Jan 2005
Location: Canada
Posts: 9
Quote:
Originally Posted by Balkrishna
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
  #4 (permalink)  
Old 09-05-2006
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,509
Quote:
Originally Posted by hkhan12
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
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.
  #5 (permalink)  
Old 09-06-2006
haiudhaya haiudhaya is offline
Registered User
  
 

Join Date: Jun 2002
Location: India (Chennai)
Posts: 4
echo "MaxChannels=600
MaxActiveChannels=600
MaxInitiators=22" >> file_name

Just give your file name after redirection operator.
  #6 (permalink)  
Old 09-08-2006
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
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\
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:20 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0