Hi,
Iam using ksh and trying to execute the following syntax to replace one word of the sentence with a new word. But somehow sed is not able to replace the old value with new value. Please let me know where Iam going wrong.
Sample Code :
-->
export line="VORTEX,abcdef"
export isname="VORTEX"
export f_new=`echo ${line} | sed -e 's/\"${isname}\"/IDEA/g'`
echo ""$f_new
-->
Expected Result :
IDEA,abcdef
Actual Result obtained :
VORTEX,abcdef
Yoda
May 29, 2013, 11:20am
2
export f_new=`echo ${line} | sed -e "s/$isname/IDEA/g"`
1 Like
Hi Yoda,
Thanks It is working.
But what I didn't get is why single quotes is not working.
Not able to understand when to use single quoates and double quotes.
Please advise.
Yoda
May 29, 2013, 11:31am
4
Enclosing a referenced value in double quotes (" ... ")
does not interfere with variable substitution.
This is called partial quoting, sometimes referred to as weak quoting.
Using single quotes (' ... ')
causes the variable name to be used literally, and no substitution will take place.
This is full quoting, sometimes referred to as strong quoting.
So you have to always use double quotes or weak quoting if you want to reference a variable value.
1 Like