I have a file which contains a list of file, and I want to know if these files exist. I used this command:
while read line; do
filename="$(echo $line | cut -d';' -f4)";
if [ ! -e "/some/path/$filename" ];
then echo "/some/path/$filename";
fi ;
done < "../my_list_of_file"
This command returns to me every file listed as non existent, ex:
/some/path/my_listed_file.jpg
But when I do ls /some/path/my_listed_file.jpg
, I can see that the file exists. What is wrong in my command?
Thank you to Barmar and chepner, the problem was the CRLF
on the end of the file.
Here is the working command :
while IFS=$';\r' read -r _ _ _ filename _; do
if [ ! -e "/some/path/$filename" ];
then echo "/some/path/$filename";
fi ;
done < "../my_list_of_file"