I am trying to read files from a directory into an array but even when the file doesn't exist, it is saved into the array. I want to exclude the file name if it doesn't exist.
a=(/tmp/nofileexists) && echo ${#a[@]} && echo ${a[@]}
1
/tmp/nofileexists
The path may contain a wild card.
a=(/tmp/nofileexists*.pdf) && echo ${#a[@]} && echo ${a[@]}