You are not logged in.
Stupid question probably..
Say I have a script that uses the variable $HOME, and I want to replace it with /another/dir using sed
I try something like..
sed -i "s_$HOME/file_/another/dir/file_g" script.sh
but its a no go, I think sed expands $HOME to /home/tj and fails to find it in the script. How to avoid this?
Last edited by tjwoosta (2011-03-02 05:57:06)
Offline
You want to wrap the s/ expression in single quotes, then. That's not sed, though, but bash. This should prove enlightening (-:
Offline
Thanks
Offline
Glad to help!
Offline
alternatively you could escape the $, if you wanted to mix some expanded vars and some not:
sed -i "s_\$HOME/file_/another/dir/file_g" script.sh
That should also work.
Offline