I'm making a generic bash script whose input $1 is file pattern that it wants to iter through. Right now I have
for entry in ./$1; do
$ ./stuff.sh PRM*
When you call
PRM* is expanded by the shell to the matching files.
If you want to pass the pattern without expansion, then you have to quote it:
But actually, it will be better to just let the shell expand it (don't quote it, use it as in your example), but change your script to take multiple arguments, like this:
for entry; do echo "$entry" done
That's right, there is no "in" after
for entry. None needed.
for loop uses the positional parameters by default in the absence of an "in" clause.
In other words, the above is equivalent to this:
for entry in "$@"; do echo "$entry" done