I am thinking to replace a string in linux, the idea is to find all files having abc as string and replace with xyz inside a directory and all sub-directories.
Can you suggest how can I do this with Linux shell scripting
You can use find and sed, since sed will only affect files which have this string. If a file does not have the string, there's no disadvantage of running the replace anyway:
find -type f -exec sed -i 's/abc/xyz/g' {} +
-type f
only find files (exclude directories)-exec
for each file found execute …sed -i
edit files in-places/abc/xyz/g
replace all occurrences of "abc" with "xyz" in all lines{} +
invoke the "exec" command with multiple file names at once, instead of once per file
find
+sed
. What have you attempted, why does it not work?