I'm trying to iterate all files in a directory that have the FILELIST extension, which I manage to do. But then I would like to read the content of these files, containing paths and file names of other files. These files, I would like to move to another location.
# Iterate all file lists
for fl in /path/Inbox/*.FILELIST
#Iterate the content of the current file list
while read line;
#Move it to the Archive directory...
done < $fl
Your script looks good and with a few tweaks like below, should do the job for you. I have added conditions in
read to handle special characters if available in the file you are reading from.
#/bin/bash for file in /path/Inbox/*.FILELIST do while IFS= read -r -d '' line; do echo "$line" # mv "$line" "$targetPath" # Do whatever else you want to do with the line here done < "$file" done