I have thousands of files here which i have to do a replace on. SO i am trying to create a bash program which will loop through all the old variables and replace them with new variables. So here is what i have currently.
I have a file with all the old and new variables for example: So i would need to replace the first value with the second value. I have named this file new.
web_lgl,web_lgl_index
web_matchmaker,web_matchmaker_index
web_mds,web_mds_index
web_metadata,web_metadata_index
web_mqmon,web_mqmon_index
web_pdconfig,web_pdconfig_index
web_people,web_people_index
web_pescado,web_pescado_index
now i have written a while loop as follows
while IFS="," read old new; do
find . -name "savedsearches.conf" -exec sed "s/$old/$new/g" '{}' \;
done < new
this does work. it replaces the old value with the new value. but in the savedsearches.conf file i am trying to target specific strings to get replaced for example
index="web_lgl"
index = "web_matchmaker"
index= "web_pdconfig"
and not some random sentence in the file like for example
description: web_lgl contains AWS data. which is collected from AWS.
SO i need to tweak my bash script so that i can target only the variables with index= as the starting part and ignore every other occurence of the string. I have tried adding index= to the bash program but i am not getting any hits. for example the below code does not produce any hits.
while IFS="," read old new; do
find . -name "savedsearches.conf" -exec sed "s/index=$old/index=$new/g" '{}' \;
done < new
Is there any way to tweak my bash script so that it specifically targets values after index= instead of any random sentence that the find command finds?