I run this code for getting the list of directories from input file and return last file in each directory
#!/bin/bash
while IFS= read -r line; do
echo "Text read from file: $line"
ls $line -ltrh |tail -1
done < "$1"
but its not working with this error
[root@localhost /]# ./last_file.sh new2.txt
Text read from file: 17609
No such file or directory
Text read from file: 17601
: No such file or directory
Text read from file: 17608
: No such file or directory
Text read from file: 17610
: No such file or directory
Text read from file: 12465
: No such file or directory
Text read from file: 12356
: No such file or directory
Text read from file: 34562
: No such file or directory