I need to get all the .config file in a given directory and in each of these file I need to search for a specific string and replace with another based on the file.
If you are on Unix like platform, you can do it using Perl on the command line; no need to write a script.
perl -i -p -e 's/old/new/g;' *.config
TO be on the safer side, you may want to use the command with the backup option.
perl -i.bak -p -e 's/old/new/g;' *.config