system
January 2, 2002, 5:22pm
1
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
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.
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.
system
January 3, 2002, 1:07pm
4
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
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,
arunnr
August 31, 2007, 3:43am
6
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