There are some 10 files say file a, file b, file c,...file j. I have to search all these files and replace the string "xyz" with "abc". Most important this has to be done with a shell script using for loop and sed command.can somebody provide the solution here
Asked
Active
Viewed 1.2k times
1 Answers
8
Use sed
sed -i s/xyz/abc/g files
-i
will edit the files in places///
will specify the substitution (read the manual for the details)g
will replace more than one occurrence per line
for example
sed -i s/xyz/abc/g a b c d e f g h i j
or for all the files in the directory
sed -i s/xyz/abc/g *
Why a loop?

Matteo
- 14,696
- 9
- 68
- 106