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
1 Answer
Use sed
sed -i s/xyz/abc/g files
-iwill edit the files in places///will specify the substitution (read the manual for the details)gwill 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?