On 7/28/10 6:33 AM, Martin McCormick wrote:
I could have sworn I have done this before but obviously
not because I can't get it to work no matter what I try.
I am running a shell script that is supposed to find
every .zip or .ZIP file in a directory and do an extraction of
the contents. I don't want any other files to be included in the
script as they are not zip files. What works exactly from the
command line is:
ls *.[Zz][Ii][Pp]
I get any .zip or .ZIP file that is in the directory. In the
script, there is some code as follows:
for MAGFILE in `ls *.[Zz][Ii][Pp] $MAGDIR/`; do
#lots of other stuff
done
I think I have tried about every form of escaping there
is and the error is that *.[Zz][Ii][Pp] is no such file or
directory.
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.
Many thanks for any suggestions or explanations as to
why this does not seem to work.
Martin McCormick
#!/bin/sh
for MAGFILE in $(ls *\.[zZ][iI][pP])
do
echo "File: $MAGFILE";
done
I would prefer to rely on $() before `` in a bash script.
--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/4c501d35.1020...@envygeeks.com