Register
It is currently Wed Jul 30, 2014 3:06 am

Inserting lines into a file


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Tue May 19, 2009 11:14 am   

Joined: Tue May 19, 2009 11:10 am
Posts: 1
Hi,

I am having trouble inserting lines into a file via a Unix shell script, can anyone out there help me with this?

Part of my file content looks like this:

# default ssl qop
[ssl-qop-mgmt-default]
default = ALL

I now need this part to read as follows:

# default ssl qop
[ssl-qop-mgmt-default]
default = DES-168
default = RC2-128
default = RC4-128
#default = ALL

How do I input those 3 lines into the file while commenting out the "default = All" ?


Top
 Profile  
 PostPosted: Sun Jun 21, 2009 3:47 am   

Joined: Sun Jun 21, 2009 3:23 am
Posts: 4
Code:
#!/bin/bash

sed -i '3i default = DES-168' file
sed -i '4i default = RC2-128' file
sed -i '5i default = RC4-128' file
sed -i 's/default = ALL/#default = ALL/' file


This will do it, however, I do not know what the entire content of your file looks like. The '#i' in each sed command inserts the statement BEFORE that line number. So, make a copy of your file and test it out replacing the line number that's in my script.

-twantrd


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP