Re: How to skip small files in a for loop
thomasriise wrote:
> I e.g. have this script:
>
> ---------------------------------
> #!/bin/ksh
>
> numfiles=`ls fil* | wc -w | sed 's/ *//'`
> files=`ls fil*`
> echo "there are $numfiles files to process"
>
> doit(){
> for i in $files
> do
> list=`ls -ut $i`
> size=`ls -lut $i 2>/dev/null | awk '{print $5}'`
> if [ $size -lt 630 ]
> then
> done
If you want to skip the file then use
continue
if you want to leave the loop then use
break
instead of done.
Janis
> fi
> echo $list
> done
> }
>
> doit
> ---------------------------------
>
> My shell reports that the done in line 15 is unexpected. Is there
> another way to skip the files smaller than the specified size? Or
> should I just do that before the loop should begin?
>
> Thanks.
|