ok, so here is the issue, I have 2 arrays.
I need to be able to create a loop that will find ${ARRAY1[1] in the text doc, and replace it with ${ARRAY2[1] then write the results. I already have that working. The problem is, I need it to do that same result across however many items are in the 2 arrays (they will always be an equal # and will always match instances in the target text file)
So, here is what I have so far
Quote:
LOOP=${#READ[@]}
for i in $(eval echo {0..$LOOP})
do
sed -e 's/'${ARRAY1[$i]}'/'${ARRAY2[$i]}''/'g' ${FILE}.txt
done
This is doing what I need it to do. The problem tho, is that, obviously it is printing ${FILE}.txt over and over and in each instance it is replacing the corresponding array value.
I need do the find/replace across all arrays then output the final result to a new file that contains all of the new data.
I tried:
Quote:
cp $FILE.txt ${FILE}_renamed.txt
LOOP=${#READ[@]}
for i in $(eval echo {0..$LOOP})
do
sed -e 's/'${ARRAY1[$i]}'/'${ARRAY2[$i]}''/'g' ${FILE}_renamed.txt > ${FILE}_renamed.txt
done
thinking, logically that would do the find and replace, open the new version containing the first find and replace do the next, etc until it resulted in what I need.
I end up with a blank document.
can somebody please tell me where I'm going wrong here.
I'm so close, I just don't know where to go from here!