I am wondering why the following command wouldn't work:

sudo find . -name index.htm | xargs -0 sudo sed -i 's/pattern1/pattern2/g'

When ran the two commands separately, they worked as expected, find found all the files I was needing to change, and sed correctly replaced the text according to the regex (obviously when i ran the sed command separately i supplied a filename as an argument). When running them together with xargs -0, I got

    ./lastfolder/index.htm: No such file or directory

I ended up using

sudo find . -name index.htm -exec sudo sed -i 's/pattern1/pattern2/g' {} \;

and it worked fine, I was just curious why using xargs didn't work....


You didn't use the -print0 option with find.


Are there any spaces in the directory or file names?

  • a question is seldom an answer. – user1686 Feb 13 '10 at 17:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy