Reputation: 829
I have a sed command something like this to comment out a particular line based on a particular pattern:
sed -e '/$OLD_VERSION/ s/^#*/#/' -i /ws/usernam/workspace/scripts/raw-vobs-config-spec
Here we need to comment out the line containing $OLD_VERSION
. I have passed $OLD_VERSION
as a parameter in my shell script.
Upvotes: 0
Views: 1056
Reputation: 63481
When you use single quotes in a shell, it prevents ordinary variable expansion, and so $OLD_VERSION
will not expand. Since you don't have any other characters requiring escaping, the fix should be as simple as using double-quotes:
sed -e "/$OLD_VERSION/ s/^#*/#/" -i /ws/usernam/workspace/scripts/raw-vobs-config-spec
Upvotes: 1