suppose I want to replace abc
with xyz
in all files in a directory. How do I write a script for this ?
Asked
Active
Viewed 6,911 times
0

Alex Jones
- 6,353
1 Answers
3
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.

Sreeraj
- 5,062
find . -maxdepth 1 -type f | xargs sed -i 's/abc/xyz/g'
- this is non-recursive, ie., it will replaceabc
in the files that reside only in your current working directory. – Sreeraj Nov 26 '14 at 06:42find ... -exec sed '...' {} +
– mikeserv Nov 26 '14 at 07:21