Trying to search and replace recursively across multiple files on a mac running OS X using the following command:

grep -rl string1 ./ | xargs sed -i ''  s/string1/string2/g \;

but it returns the following error:

sed: ;: No such file or directory

1 Answer 1


Remove the \; at the end:

grep -rl string1 ./ | xargs sed -i ''  s/string1/string2/g
  • As an explanation: @Das probably copy and pasted from a find command, which expects a \; after the last arg to the -exec option.
    – Arne
    Aug 15, 2014 at 8:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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