How can I replace \"abc\"
with \"abcd\"
on all files of a folder using shell?
Is it possible using sed
command?
Yes:
find /the/folder -type f -exec sed -i 's,\<abc\>,&d,g' {} \;
sed -i 's/abc/&d/g' *
should work.
Try the following command for the file file.txt:
sed -i 's/abc/abcd/g' file.txt
Try the following command for all files in the current folder:
find . -maxdepth 1 -type f -exec sed -i 's/abc/abcd/g' {} \;
For the files in the current directory and all subdirectories:
find . -type f -exec sed -i 's/abc/abcd/g' {} \;
Or if you are fan of xargs:
find . -type f | xargs -I {} sed -i 's/abc/abcd/g' {}