Pregunta

I am trying to search and replace the text of a single line with sed characters inside that line. The line is a file path thus it has /*. instead of it. I have searched and found n\ and opposing \ but non of these seem to work. Whatever I am doing wrong it's simple, but I can't see the tree through the forest.

data to edit:

Include conf.d/*.conf

I am trying to edit the

conf.d/*.conf 
conf.d/vhosts/*.conf

Include is else where in the file, but this is the only occurrence where it's the first word. this is what I have so far:

sed -i "/^Include/ s/\conf.d/*.conf\/ */\conf.d/vhosts/*.conf\/" /etc/httpd/conf/httpd.conf

I've alsow tried

sed -i "/^Include/ s/[conf.d/*.conf]/[conf.d/vhosts/*.conf]/g" /etc/httpd/conf/httpd.conf

This is the standard search error message:

Error Message: sed: -e expression #1, char 29: unknown option to `s'

I know it's something simple, but I can't seem to figure it out. I have been stuck on this for the past hour. If I can get past this, then I can edit the documentroot and other elements with sed like characters.

sed version GNU sed version 4.2.1

¿Fue útil?

Solución

sed -i "s|conf.d/\*.conf|conf.d/vhosts/\*.conf|g" /path/to/file
  • Changed Separator to |
  • Escaped asterisk
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top