1

I am confused a little bit. I would like to swap 2 directory in the apache2 config files with the sed program.

APACHE_CONF=/etc/apache2/apache2.conf
FULL_DIR=/home/$USER/new
DEFAULT_DIR=/var/www/html`

This works fine:

sudo sed -i.bak 's|'$DEFAULT_DIR'|'$FULL_DIR'|' "$APACHE_CONF"

These are not (these don't have error, just do nothing):

sudo sed -i.bak 's/"$DEFAULT_DIR"/"$FULL_DIR"/' "$APACHE_CONF"
sudo sed -i.bak 's/\"$DEFAULT_DIR"/\"$FULL_DIR"/' "$APACHE_CONF"

Can anybody explain why don't these work and why does the first one work?

muru
  • 207,228
ampika
  • 133

0 Answers0