The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
set Working day in ksh Rafael.Buria Shell Programming and Scripting 1 10-09-2007 01:42 AM
Not working Mandab Shell Programming and Scripting 7 05-11-2007 06:23 PM
FTP is not working. ronald_brayan Security 10 04-04-2007 05:23 AM
^P Not working on AIX. akbar AIX 0 02-24-2007 03:52 PM
why is this not working? matt2kjones UNIX for Dummies Questions & Answers 2 07-09-2002 12:58 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-18-2006
Registered User
 

Join Date: Mar 2005
Posts: 15
sed not working

Hi,

Iam doing the following using sed in a script , it is NOT working

line_old= 3754|Yes|Yes
line_new= 3754|Yes|Yes|Yes|Yes

sed -e 's/$line_old/$line_new/' data.$$ > tmp.$$
mv tmp.$$ data.$$

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

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,639
Quote:
Originally Posted by baanprog
Hi,

Iam doing the following using sed in a script , it is NOT working

line_old= 3754|Yes|Yes
line_new= 3754|Yes|Yes|Yes|Yes

sed -e 's/$line_old/$line_new/' data.$$ > tmp.$$
mv tmp.$$ data.$$

Regards
Drop the single quotes and introduce double quotes.
Reply With Quote
  #3 (permalink)  
Old 09-18-2006
tayyabq8's Avatar
UNIX Hobbyist
 

Join Date: Nov 2004
Location: /World/Asia/MiddleEast/Kuwait/Salmiya
Posts: 513
Vino,

It was an interesting thing to know about, can you pls explain the logic behind.

Regards,
Tayyab
Reply With Quote
  #4 (permalink)  
Old 09-18-2006
Registered User
 

Join Date: Mar 2005
Posts: 15
That was awesome

It worked thanks
Reply With Quote
  #5 (permalink)  
Old 09-18-2006
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,639
Quote:
Originally Posted by shereenmotor
Vino,

It was an interesting thing to know about, can you pls explain the logic behind.

Regards,
Tayyab
See the section QUOTING under man sh. Its too big to quote here. But this is what you are looking for..
Code:
       Enclosing  characters  in  double quotes preserves the literal value of
       all characters within the quotes, with the exception of $,  `,  and  \.
       The  characters  $  and  `  retain  their special meaning within double
       quotes.  The backslash retains its special meaning only  when  followed
       by one of the following characters: $, `, ", \, or <newline>.  A double
       quote may be quoted within double quotes by preceding it with  a  back-
       slash.
Reply With Quote
  #6 (permalink)  
Old 09-18-2006
tayyabq8's Avatar
UNIX Hobbyist
 

Join Date: Nov 2004
Location: /World/Asia/MiddleEast/Kuwait/Salmiya
Posts: 513
Vino, thanks for your reply. I know a double quote is used to preserve the literal value of characters, thing of interest was difference between single and double quote.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:40 AM.


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

Content Relevant URLs by vBSEO 3.2.0