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

shell game


Using a bash shell script (/bin/sh), I need to know how to check to see
if certain files exist in a directory, as in, "Are there any jpegs in
this directory?".  I've tried various things (like using -s, -f with
test and a do/for loop) but nothing seems to work right.  The closest I
can come is

if test `ls /opt/images/*.jpg | wc -l` -gt 0 then ...

Unfortunately, this gives me the error message "ls: /opt/images/*.jpg:
No such file or directory" when there are no jpegs in /opt/images.

So what am I missing here?


Drew Cohan

Reply to: