sed question
Hi all,
I am facing a problem with sed. I want to replace a constant string with an environment variable $BASEDIR. I tried sed -e "s/this/$BASEDIR/g" temp.txt sed -e 's/this/'"$BASEDIR"'/g' temp.txt but it gives me an error sed: -e expression #1, char 13: Unknown option to `s for both the cases. Any help would be appreciated. Thanks. |
The problem is due to the variable containing a forward slash, which is what you are using a a separator in the sed command. Try this instead:
sed -e 's#this#'"$BASEDIR"'#g' temp.txt |
Please use the search function this forum provides before posting, I answered this question twice in the last 48 hours......
http://www.linuxquestions.org/questi...hreadid=227588 http://www.linuxquestions.org/questi...hreadid=228454 Hope this helps. |
it works jschiwa.
I did try to search but couldnt relate the things that were there to my problem so this post. Thanks for the replies. |
All times are GMT -5. The time now is 11:14 AM. |