[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Shell Expansion in Bourne Shell Script Question



On 28.07.2010 20:05, Karl Vogel wrote:
On 28.07.2010 14:42, Jochen Schulz wrote:

J>  I think you meant to write
J>      for MAGFILE in `ls $MAGDIR/*.[Zz][Ii][Pp]`
J>  Another hint: you don't need 'ls' for your case at all.

    I'd recommend keeping the "ls".  Try your script when MAGDIR doesn't
    have any zipfiles, and MAGFILE will hold the expanded value of $MAGDIR
    with the string "*.[Zz][Ii][Pp]" appended.  Bash, sh, and ksh all do
    that for some dopey reason, which is why I would do

       for file in $(ls $MAGDIR/*.[Zz][Ii][Pp] 2>  /dev/null); do  ...

    if there's any chance that you won't find any files.


Now that's an odd one! Didn't know that.
One might be better of with some like this:

find /DIR -regextype posix-egrep -regex '.*\.(zip|ZIP)' -exec some_command {} +


Best regards

Mart


Reply to: