[Cialug] [OT]: Shell script globbing
Daniel A. Ramaley
daniel.ramaley at DRAKE.EDU
Thu Dec 20 13:33:21 CST 2007
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
>
>> I have what should be a simple shell scripting problem. If any .bad
>> files exist, then the script should do some stuff (display an error,
>> do some cleanup, and exit, though for testing i've simplified it).
>> So far i've come up with 2 solutions, one requiring a variable and
>> running "ls", the other requiring a seemingly superfluous "for"
>> loop. Is there a more elegant solution i've not discovered?
------------------------------------------------------------------------
Dan Ramaley Dial Center 118, Drake University
Network Programmer/Analyst 2407 Carpenter Ave
+1 515 271-4540 Des Moines IA 50311 USA
More information about the Cialug
mailing list