ls -ltr a list of filenames-with-spaces within a text file

OS: RHEL 5.8
shell: bash 3.2.25

Directory /home/guest/ contains these files:
file a
file b
file c
fileD
fileE
fileF
testFile.txt

I'm trying to find the syntax to run

ls -ltr

against this list of files that is contained within a text file, testFile.txt.

The file testFile.txt has the contents below, with file names within quotes and with files space delimited.

"/home/guest/file a" "/home/guest/file b" "/home/guest/file c" "/home/guest/fileF" "/home/guest/fileE" "/home/guest/fileD"

All attempts are failing upon encountering whitespace.
1.

ls -ltr `cat testFile.txt | xargs -0` 
 ls: "/home/guest/file: No such file or directory
 ls: a": No such file or directory
 ls: "/home/guest/file: No such file or directory
 ls: b": No such file or directory
 ls: "/home/guest/file: No such file or directory
 ls: c": No such file or directory
 ls: "/home/guest/fileF": No such file or directory
 ls: "/home/guest/fileE": No such file or directory
 ls: "/home/guest/fileD": No such file or directory
  1. Same error from
ls -ltr `awk '{print}' /home/guest/testFile.txt
  1. Same error from
cat testFile.txt | while read i ; do ls -ltr $i ; done 

Any assistance would be greatly appreciated. Thanks!

while read i
do
   ls -ltr "$i"
done < testFile.txt
ls -ltr $(sed -e 's|\" \"|\n|g' -e 's|"||g' testFile.txt)

Try:

xargs ls -ltr < testFile.txt
1 Like

Thanks, Scrutinizer! That worked perfectly.