I'd like to globber for files in a bash loop, something like this:
for file in filepattern???; do
# some command
done
But, if there are no files that match filepattern???, then this loop executes once with file=filepattern??? exactly, with the question marks in it. I could try this:
for file in $(ls filepattern???); do
# some command
done
That works in a shell, but in a script the failed ls command causes the script to terminate. I'm currently using:
for file in $(for ffile in filepattern???; do echo $ffile; done | grep -v ?); do
# some command
done
That works, but it's really awkward. Any thoughts?