Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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....

share|improve this question

2 Answers 2

up vote 4 down vote accepted

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

share|improve this answer

Are there any spaces in the directory or file names?

share|improve this answer
a question is seldom an answer. –  hop Feb 13 '10 at 17:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.