[Cialug] [OT]: Shell script globbing

Kendall Bailey krbailey at gmail.com
Thu Dec 20 13:42:51 CST 2007


You might want to discard the error message when no bad files exist

if [ `ls *.bad 2> /dev/null | wc -l` -gt 0 ]



On Dec 20, 2007 1:33 PM, Daniel A. Ramaley <daniel.ramaley at drake.edu> wrote:
> I like that solution. It relies on 2 external programs (ls and wc), but
> doesn't require variables or a for loop. Thanks!
>
> On Thursday 20 December 2007 13:07, Chris Freeman wrote:
> >I would do this:
> >
> >if [ `ls *.bad | wc -l` -gt 0 ]
> >   then
> >   echo Bad
> >   fi
> >


More information about the Cialug mailing list