Ajay Kulkarni Ajay Kulkarni - 2 months ago 22
Linux Question

sed command returns error

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

Answer

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