Please use [code][/code]
tags around your code and data, to preserve formatting and to improve readability. Please do not use quote tags, colors, or other fancy formatting.
You might want to try giving us some actual examples of filenames and directory trees to work with, rather than trying to describe them.
Anyway, your loop is very close, except: don't read lines with for
Use a while+read
loop instead. Or read the file into an array
first with the mapfile
command, and loop over that.
As for your new requirement, I suggest simply adding a case
statement to the loop to test the naming pattern of each file, and run the appropriate command.
case $file in
xxx*) <move file xxx command> ;;
yyy*) <move file yyy command> ;;
*) echo "unknown filename" ;;
It would also be a good idea to add some intermediate tests too, to ensure that each file is actually available, as is the target, before trying to move it.
The Bash Guide is a good resource that covers all the basics of scripting. Check it out: