The *
is a so-called "glob" and will be expanded by the bash as "all files in the current directory", so it will basically expand to a space-separated list of all files in the current directory (which is the format commonly expected by many bash builtin flow-control constructs).
Globs can be used not only stand-alone but also as part of expressions, so assuming you have a directory stored in a bash variable $searchdir
(be careful in naming bash variables in order not to accidentally overwrite essential environment variables such as $PATH
) the construct
select s in "$searchdir"/*
will expand to "all files in $searchdir
".
Note, however, that if the directory happens to be empty, the expression will amount to a literal *
(or literally /the/actual/value/pointed/to/by/searchdir/*
) unless you have set the nullglob
option via
shopt -s nullglob
Then, if the directory is empty, the glob construct will expand to an empty list which is usually what you will want.