I am trying to write a bash script that takes several variables and then does a search / replace with a given file search using grep to get a list of files with a string. I think the problem I am facing is seeing the variables in sed. I'm not sure what else could be.
if [ "$searchFiles" != "" -a "$oldString" != "" -a "$newString" != "" ]; then echo -en "Searching for '$searchFiles' and replacing '$oldString' with '$newString'.\n" for i in `grep $oldString $searchFiles |cut -d: -f1|uniq`; do sed -i 's/${oldString}/${newString}/g' $i; done echo -en "Done.\n" else usage fi
source share