Zack D
Zack D

Reputation: 23

Sed Replace return error

find ./ -type f -exec sed -i -e ’s/var\/www\/html/var\/www\/this_new_html/g’ {} \;

I tried to run the above to replace all my file that have the following

include_once '/var/www/html/inc/functions.php';

into

include_once '/var/www/this_new_html/inc/functions.php';

I had many includes line so using a mass replace sed replace would be good but when I run the code

find ./ -type f -exec sed -i -e ’s/var\/www\/html/var\/www\/this_new_html/g’ {} \;

The error print out was

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

How do i change to make it working to replace

Upvotes: 0

Views: 115

Answers (1)

PesaThe
PesaThe

Reputation: 7509

Don't use , use single quotes '. Also, I recommend using a different delimiter when working with paths. Using # will improve readability significantly:

find . -type f -exec sed -i 's#var/www/html#var/www/this_new_html#g' {} +

Upvotes: 3

Related Questions