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

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

1 Answer

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

Your Answer

 
discard

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.