I’m using a bash script to copy specific files listed in a file, into another directory. The issue is that those filenames are not being recognized as such and i get an error ‘ ‘ ‘file not found’
The files do exist and I am in the correct directory.
Thing is if I use a list of filenames obtained by ls > list_of_files it works no issue (though this gives me all files and I only want specific ones). This also works if I write the filenames in by hand.
To the naked eye both file lists look the same, what could be the issue here? It kind of seems like it only reads part of the string as a filename or a space?
The structure of filenames is a such AAA-000.a_a.png
Below is the copying part of the script
while IFS= read -r file;do
if [ -f "$file" ]; then
cp "$file" "$destination"
else
echo "file '$file' not found"
fi
user1379237 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.