Ajay Kulkarni
Ajay Kulkarni

Reputation: 3039

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

Upvotes: 0

Views: 55

Answers (1)

Arjun Mathew Dan
Arjun Mathew Dan

Reputation: 5318

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

Upvotes: 1

Related Questions