Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sed: can't read : No such file or directory

I am running the following command:

find . -name '*.html' -exec sed "s/foo/bar/g" {} \;

where the file structure looks like this:

./two/three.html
./two/two.html
./two/one.html
./three/three.html
./three/two.html
./three/one.html
./one/three.html
./one/two.html
./one/one.html

However, sed comes back saying the files could not be found, even though these two commands work fine on their own (i.e. I can run a find by itself, and I can run sed by itself fine).

I had a peer look at it with me, and he was stumped also. I ended up going a different route, but I'd still like to know what exactly is going wrong here.

like image 538
Zac Lozano Avatar asked Mar 28 '14 14:03

Zac Lozano


1 Answers

Thanks to glenn jackman for the advice:

I needed to place quotes around the brackets as such:

-exec sed "s/foo/bar/g" '{}' \;

Rather than how I initially posted it.

like image 176
Zac Lozano Avatar answered Oct 03 '22 04:10

Zac Lozano