Re: Shell Expansion in Bourne Shell Script Question
> for MAGFILE in `ls *.[Zz][Ii][Pp] $MAGDIR/`; do
> #lots of other stuff
> done
As others noted, the ls command is superfluous and possibly harmful
here.
One more thing you can do is case-insensitive pathname expansion:
shopt -s nocaseglob
for MAGFILE in $MAGDIR/*.zip
do
#lots of other stuff
done
That will work with bash (begin your script with #!/bin/bash) but not
with dash as far as I know.
> If I leave out the attempted regular expression of
> *.[Zz][Ii][Pp], the loop works but then any other non-zip or
> non-ZIP files get processed.
Note that that is not a regular expression, it's a shell pattern or
glob pattern. They are different, and used in different contexts. Both
are immensely useful.
Cheers,
Reply to: