The problem with your solution is what whizje already pointed out, two posts above. The loop
Code:
for file in *.txt
do
mv $old $new
done
is dummy, since it doesn't use the loop variable "file" in its body. Furthermore upon the shell substitution of the two variables "old" and "new" with their values, you end-up with a command line like this:
Code:
mv a.txt b.txt c.txt abby.txt barry.txt cindy.txt
that is not as expected and wrong, since you can move multiple files at once, but only when the last argument is the name of a directory (the destination).
Regarding the array solution, jschiwal already provided it in post #2. You have just to translate its words into shell code. Here is a working example of what you can obtain..
1) first assign the content of the two files to two different arrays (as shown above)
Code:
orignames=( $(cat old) )
propnames=( $(cat new) )
here we use command substitution $(command) to retrieve the content of the files, and array assignment using parentheses.
2) do a loop over the array indexes, but take in mind that they are zero-based, that is the first index is 0, the second one is 1 and so on...
Code:
for ((i=0; i < ${#orignames[*]} ; i++))
do
echo mv ${orignames[i]} ${propnames[i]}
done
here I used a C-style for loop (which is permitted in bash), but you can try a different syntax and even a while loop, if you prefer. The syntax ${#orignames[*]} returns the length of the array, as you already should know. The echo statement is just for testing purposes (it prints out the command without actually executing it).
Hope this helps. Keep up your learning process from the basics and you will see that at some point you will spare a lot of time to accomplish both simple and complex tasks.