I have a file that contains
coffe
milk
water
etc..
I want to comment out one line, e.g., milk
using a variable that contains milk
or #milk
.
I'm trying to use #
as switch.
checkval="milk"
When I use
sed 's/^.//' $file
this remove the first character on all lines.
When I use
sed -e "s/$checkval/\#$checkval/g" $file
this works by adding #
.
I expect the following output file when the variable contains the value #milk
:
coffe
milk
water
The expected output when the variable contains the value milk
:
coffe
#milk
water