The UNIX and Linux Forums  

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 here.

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 09-11-2006
Registered User
 

Join Date: May 2005
Posts: 15
SED help

Hi guys

I am trying to append a switch to a line in an rc file, but it doesnt seem to be working:

when i run this command :

cat rc.tcpip |sed "s/syslogd "$src_running" /syslogd "$src_running" "-N" /"
it still reads:
start /usr/sbin/syslogd "$src_running"

Any ideas - I've tried every combination of syntax I know?? Or should I not be using sed ?

Thanks
Reply With Quote
Forum Sponsor
  #2  
Old 09-11-2006
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,698
Quote:
Originally Posted by serm
Hi guys

I am trying to append a switch to a line in an rc file, but it doesnt seem to be working:

when i run this command :

cat rc.tcpip |sed "s/syslogd "$src_running" /syslogd "$src_running" "-N" /"
it still reads:
start /usr/sbin/syslogd "$src_running"

Any ideas - I've tried every combination of syntax I know?? Or should I not be using sed ?

Thanks
Try

Code:
sed "s/syslogd $src_running /& -N /g" rc.tcpip
Reply With Quote
  #3  
Old 09-11-2006
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Code:
sed "s/syslogd "$src_running" /syslogd "$src_running" -N /" rc.tcpip > temp
mv temp rc.tcpip
or

Code:
perl -pi -e "s/syslogd "$src_running" /syslogd "$src_running" -N /" rc.tcpip

Last edited by anbu23; 09-11-2006 at 09:19 AM.
Reply With Quote
  #4  
Old 09-11-2006
Registered User
 

Join Date: May 2005
Posts: 15
Quote:
Originally Posted by anbu23
sed "s/syslogd "$src_running" /syslogd "$src_running" -N /" rc.tcpip > temp
mv temp rc.tcpip

or

perl -pi -e "s/syslogd "$src_running" /syslogd "$src_running" -N /" rc.tcpip

I still makes no change :

sed 's/syslogd $src_running /$src_running "-N" /g' rc.tcpip > ./temp
outputs:
start /usr/sbin/syslogd "$src_running"

i need it to read:
start /usr/sbin/syslogd "$src_running" "-N"
Reply With Quote
  #5  
Old 09-11-2006
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Code:
sed 's/syslogd \"\$src_running\" /& "-N"' rc.tcpip > ./temp
if this doesn't solve your problem can you show me your input file?

Last edited by anbu23; 09-11-2006 at 09:19 AM.
Reply With Quote
  #6  
Old 09-11-2006
Registered User
 

Join Date: May 2005
Posts: 15
Quote:
Originally Posted by anbu23
sed 's/syslogd \"\$src_running\" /& "-N"' rc.tcpip > ./temp
if this doesn't solve your problem can you show me your input file?
Hi

its still not working !! i've been scratching my head all day over it !

Here is a part of the rc.tcpip file - just the one line needs changed:
# Start up syslog daemon (for error and event logging)
start /usr/sbin/syslogd "$src_running"

# Start up print daemon
#start /usr/sbin/lpd "$src_running"

# Start up routing daemon (only start ONE)
#start /usr/sbin/routed "$src_running" -q
#start /usr/sbin/gated "$src_running"


And I used your command:

sed 's/syslogd \"\$src_running\" /& "-N"/' rc.tcpip > ./temp
root > cat temp|grep -i syslogd
start /usr/sbin/syslogd "$src_running"
Reply With Quote
  #7  
Old 09-11-2006
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Code:
sed 's/syslogd \"\$src_running\"[SPACE]/& "-N"/' rc.tcpip > ./temp
In your code there is a space. Just remove the space and use.
Code:
sed 's/syslogd \"\$src_running\/& "-N"/' rc.tcpip > ./temp
Now it should work.

Last edited by anbu23; 09-11-2006 at 08:42 AM.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:26 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0