This question already has an answer here:

suppose I want to replace abc with xyz in all files in a directory. How do I write a script for this ?

marked as duplicate by jasonwryan, slm Nov 26 '14 at 7:35

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


find . -type f | xargs sed -i 's/abc/xyz/g'

Use -maxdepth option if you don't want the action to take place recursively in your current working directory.

  • find . -maxdepth 1 -type f | xargs sed -i 's/abc/xyz/g' - this is non-recursive, ie., it will replace abc in the files that reside only in your current working directory. – Sree Nov 26 '14 at 6:42
  • 2
    you should use find ... -exec sed '...' {} + – mikeserv Nov 26 '14 at 7:21

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