Take the 2-minute tour ×

I want to implement the following command recursively

sed -i 's/href=\"1\//href=\"\/1\//g' ./*

so that it replaces all href="1 with href="/1 in all sub-directories. Is there a flag I can add to this command to achieve the results I want?

share|improve this question

1 Answer 1

up vote 6 down vote accepted
find . -type f -print0 | xargs -0 sed -i 's/href=\"1\//href=\"\/1\//g'
share|improve this answer
the -o option doesn't exist...what does that do? –  John Aug 20 '10 at 16:45
It should be -0 - it matches up with -print0 in the find - edited the post. –  James Aug 20 '10 at 16:46
oh wait, maybe you meant -0 ... i tried the -0 and seemed to have done the trick –  John Aug 20 '10 at 16:46

Your Answer


