You can also test the exit code from ls to determine if the files exist. The code below seems to work. #!/bin/sh if ls *.bad > /dev/null 2>&1 ; then echo bad; fi Kendall Bailey wrote: > You might want to discard the error message when no bad files exist > > if [ `ls *.bad 2> /dev/null | wc -l` -gt 0 ] >