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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
awk Shell Script error : "Syntax Error : `Split' unexpected Herry UNIX for Dummies Questions & Answers 2 03-17-2008 11:16 AM
error during run: St9bad_alloc - Getting this error while using some conversion progr sathu_pec Shell Programming and Scripting 1 01-21-2008 02:38 AM
I got error like...syntax error on line 1, teletype koti_rama UNIX for Advanced & Expert Users 2 07-07-2007 08:35 PM
error reading sections error at install doelman SUN Solaris 2 02-05-2007 12:21 PM
Error: Internal system error: Unable to initialize standard output file firkus UNIX for Dummies Questions & Answers 2 10-25-2005 04:23 PM

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

Join Date: Nov 2007
Posts: 70
sed error

in a bash shell I have the following

S00="BLOCK-NAMES /ELM1 /SAUT0 /FIT00 FOR ELMT,SAMPLE,FIT"
S01="BLOCK-NAMES /ELM1 /SAUT0 /FIT01 FOR ELMT,SAMPLE,FIT"

sed "s/'$S00'/'$S00'/g" pb206.cnt > tmp

sed commplains and says
sed: -e expression #1, char 29: Unknown option to `s'

Can anybody help?
Thank you!!!
  #2 (permalink)  
Old 04-28-2008
Shivdatta Shivdatta is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 73
Try this

Code:
sed 's/$S00/$S01/g' pb206.cnt > tmp

instead of

Code:
sed "s/'$S00'/'$S00'/g" pb206.cnt > tmp

  #3 (permalink)  
Old 04-28-2008
f_o_555 f_o_555 is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 70
Thank you Shivdatta, it doesn't complain anymore but it does not replace the string!
  #4 (permalink)  
Old 04-28-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
You are replacing a string with the same string, so it's quite possible that it's replacing it, but there is no way to tell.

What exactly would you expect the result to be like?
  #5 (permalink)  
Old 04-28-2008
f_o_555 f_o_555 is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 70
of course the strings are different:
here is the script

S00="BLOCK-NAMES /ELM1 /SAUT0 /FIT00"
S01="BLOCK-NAMES /ELM1 /SAUT0 /FIT01"
S02="BLOCK-NAMES /ELM1 /SAUT0 /FIT02"
S03="BLOCK-NAMES /ELM1 /SAUT0 /FIT03"

sed 's/$S00/$S01/g' pb206.cnt > tmp1
sed 's/$S00/$S02/g' pb206.cnt > tmp2
sed 's/$S00/$S03/g' pb206.cnt > tmp3

but tmp1, tmp2 and tmp3 are the same as pb206.cnt (which contains S00)
  #6 (permalink)  
Old 04-28-2008
f_o_555 f_o_555 is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 70
actually i have to replace the whole string S00 with S01
  #7 (permalink)  
Old 04-28-2008
Shivdatta Shivdatta is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 73
If in case u are trying to replace FIT00 by FIT01 then if this helps

sed 's/\(.*\)FIT00\(.*\)/\1FIT01\2/g' filename
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 01:23 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