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

Re: Shell Expansion in Bourne Shell Script Question



>> 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.

-- 
Karl Vogel                      I don't speak for the USAF or my company

Love and respect for the great American experiment
in free government does not appear out of thin air.      --Larry P. Arnn


Reply to: