I want to replace a line with double quotes on OpenBox startup, like:
(sleep 2 && terminator -e "htop") &
with
#(sleep 2 && terminator -e "htop") &
I use this command, but it does not work:
sed -i "s/(sleep 2 && terminator */#(sleep 2 && terminator -e "htop") &/" ~/.config/openbox/autostart
It gives me this error:
`sed: -e expression #1, char : unknown`
Advertisement
Answer
The ampersand in the replacement string recalls the pattern in the search string.
So you can just do this:
sed -i "s/(sleep 2 && terminator */#&/" ~/.config/openbox/autostart
Also, you can use single quotes on the outside, and double quotes on the inside or use ” on the inner double quote.
sed 's/(sleep 2 && terminator -e "htop") &/#(sleep 2 && terminator -e "htop") &/' ~/.config/openbox/autostart
or
sed -i "s/(sleep 2 && terminator -e "htop") &/#(sleep 2 && terminator -e "htop") &/" ~/.config/openbox/autostart