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
Variables bobo UNIX for Dummies Questions & Answers 1 01-19-2007 01:37 AM
doing a sed on certain variables seaten UNIX for Dummies Questions & Answers 10 09-05-2005 11:45 PM
doing a sed with variables seaten Shell Programming and Scripting 1 05-06-2005 04:08 PM
doing a sed with variables seaten UNIX for Dummies Questions & Answers 1 05-06-2005 03:48 PM
Using Variables to Set Other Variables superdelic UNIX for Dummies Questions & Answers 3 04-21-2005 11:44 AM

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 01-02-2002
sskb
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
variables in sed

when i do something like substituting a particular thing with a system variable, i am unable to do that expect the varible name getting into that.

for ex.. i tried,

sed -e 's/date/`date`/g' <if >of

but i got date replaced with "`date`" and not with the actual date ..
same case happened with a variable $var.

Can I know where I go wrong?

Thanks
  #2 (permalink)  
Old 01-03-2002
LivinFree's Avatar
LivinFree LivinFree is offline Forum Advisor  
Goober Extraordinaire
  
 

Join Date: Jul 2001
Location: Portland, OR, USA
Posts: 1,584
It's the single-quotes surrounding the s//g statement. They are there to make sure nothing sent to sed is interpretted by the shell first, and that includes back-quotes.
  #3 (permalink)  
Old 01-03-2002
negative negative is offline
Registered User
  
 

Join Date: Jan 2002
Location: Bandung, Indonesia
Posts: 11
well, see the example..

----------------------------

sh-2.05$ cat file

date

sh-2.05$ sed "s#date#`date`#" file

Thu Jan 3 20:39:08 JAVT 2002

sh-2.05$

----------------------------

i guess that's what you mean.
  #4 (permalink)  
Old 01-03-2002
sskb
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
Thanks LivinFree and Negative,
I got that and I wish to know more about these chatacterisations with sed. I could not find much info on

man sed

thanks again
  #5 (permalink)  
Old 01-03-2002
negative negative is offline
Registered User
  
 

Join Date: Jan 2002
Location: Bandung, Indonesia
Posts: 11
Well, okay.. Now for completing your HAPPINESS :)

please visit this URL, http://www.dbnet.ece.ntua.gr/~george/sed/1liners.html, i promise it will give you more info about sed.

Peace,
  #6 (permalink)  
Old 08-31-2007
arunnr arunnr is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 1
you can use double quotes instead of single quotes.. while using single quotes sed wont substitute value of variables, but using double quotes will substitute value..

example: sed "s/$var/" 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 10:01 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