Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


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.