I am trying to use the find command to gather files with a variable name as part of the title and move them to another directory. It is a loop variable representing an array, like so
for i in "${array[@]}"; do
find -name "${i}r.TXT" -a -name "${i}f.TXT" -execdir mv '{}' logs/ \;
done
The directory I am trying to move them to is a subdirectory of my current working directory, named logs. What is the correct way to integrate the variable into the filename so that find will grab the correct files and move them to the logs directory?
The elements of the array are integers, like 50, 55, 60, 65, so on and I want files that are 50f, 50r, 55f, 55r, etc.
-a(which means and) but-o(or). And I'm not sure you needfind.findsearches subdirectories (and subsubdirectories and ...), so it may find the files in the current directory, move them down intologs/, then find them again inlogs/, move them down intologs/logs/(or at least try to), etc.