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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
AWK substitution klut Shell Programming and Scripting 4 01-15-2008 11:26 AM
Bad Substitution D_Redd74 Shell Programming and Scripting 3 02-07-2007 05:48 PM
ksh substitution solea Shell Programming and Scripting 2 08-09-2004 05:30 AM
sed substitution jo_aze UNIX for Dummies Questions & Answers 3 06-23-2002 09:32 PM
substitution supercbw Shell Programming and Scripting 1 06-07-2002 03:07 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 08-17-2001
Ohji Ohji is offline
Registered User
  
 

Join Date: Aug 2001
Location: Malaysia
Posts: 3
Red face Substitution using sed

I know we can substitute a string using sed but how?

For example: sed 's/(old variable)/(new variable)/ details.dat

Am I suppose to put $old variable or whatever? Because I tried many times, it didnt work by putting $old variable. Am I suppose to enclose it with "" or ''?

Please help
  #2 (permalink)  
Old 08-17-2001
LivinFree's Avatar
LivinFree LivinFree is offline Forum Advisor  
Goober Extraordinaire
  
 

Join Date: Jul 2001
Location: Portland, OR, USA
Posts: 1,584

Well, it matters. Is $old defined somewhere? Or are you trying to take an example script and mold it to your needs? If so, you may need to define it previously in the script, like:
old= < whatever you want it to be >

If that doesn't help, can you paste that part of the script here, so we can see how it's working?
  #3 (permalink)  
Old 08-17-2001
Optimus_P Optimus_P is offline Forum Advisor  
flim flam flamma jamma
  
 

Join Date: May 2001
Location: Chicago IL, USA
Posts: 1,006
Re: Substitution using sed

Quote:
Originally posted by Ohji
I know we can substitute a string using sed but how?

For example: sed 's/(old variable)/(new variable)/ details.dat

Am I suppose to put $old variable or whatever? Because I tried many times, it didnt work by putting $old variable. Am I suppose to enclose it with "" or ''?

Please help
your missing a closeing single quote.

should be
sed 's/(old variable)/(new variable)/' details.dat
  #4 (permalink)  
Old 08-17-2001
Anshul Anshul is offline
Registered User
  
 

Join Date: Aug 2001
Location: Delhi ,India
Posts: 1
One more thing you may do is put every variable in { }.
like :
sed 's/${Old_var}/${New_var}/g' FileName
Cheer Up,
Anshul
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 06:57 AM.


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