0

I was trying to execute this command:

sudo sed -i 's/^\$projectroot.*/\$projectroot = \\"\\/home\\/repo\\";/' /etc/gitweb.conf  

It returned an error:

sed: -e expression #1, char 42: unknown option to `s'  

I don't understand why s is used in sed command. Please help

Ajay Kulkarni
  • 2,900
  • 13
  • 48
  • 97
  • Possible duplicate of [Use slashes in sed replace](http://stackoverflow.com/questions/5864146/use-slashes-in-sed-replace) – tripleee Oct 07 '16 at 08:21

1 Answers1

1

Your command should be:

sed -i 's/^\$projectroot.*/\$projectroot = \"\/home\/repo\";/'

Sample:

$ cat File

aaaaaaaaaa
bbbbbbbbbb
$projectroot
dddddddddd

$ sed 's/^\$projectroot.*/\$projectroot = \"\/home\/repo\";/' File

aaaaaaaaaa
bbbbbbbbbb
$projectroot = "/home/repo";
dddddddddd
Arjun Mathew Dan
  • 5,240
  • 1
  • 16
  • 27