I have a file ~/filelist
, where each line is a file's pathname, which may contain whitespaces:
/path/to/my file1
/another path/to/my file2
I have a script which can accept filenames as arguments:
myscript.sh "/path/to/my file1" "/another path/to/my file2"
The following commands will not work however
myscript.sh $(cat ~/filelist)
and
arr=($(cat ~/filelist))
myscript.sh "${arr[@]}"
How can I make the script work with ~/filelist
? Thanks.
ls -l "${@}"
, why does it report errorls: cannot access '"/path/to/my file1"': No such file or directory
andls: cannot access '"/another path/to/my file2"': No such file or directory
? – Tim Aug 14 '18 at 22:25eval
the command containing the filenames. – ilkkachu Aug 14 '18 at 22:41filelist
, I double quoted the pathnames which contain whitespaces – Tim Aug 15 '18 at 02:16