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
sed:
./index.htm
./folder1/index.htm
./folder1/subfolder2/index.htm
...
...
./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....