I can `sed -i 's/a/ONE/g' file.xml with no problems, but attempting to run through with a script and pass array variables wipes the entire file.
declare -a arr=("a" "b")
declare -a ray=("ONE" "TWO")
for i in "${!arr[@]}"
do
sed -n -i 's/${arr[$i]}/${ray[$i]}/g' $file
done
Expected Output:
I should be replacing all instances of a & b, with ONE & TWO respectively.
Like I said I was able to complete this from the command line with
sed -i 's/a/ONE/g' file.xml
What gives?
EDIT:
Attempted a suggested fix using double quotes in the sed
command, no luck.