I need to check for the existence of jpg, gif, and png files in a directory and if none exist I need to exit with an error. The existence check needs to be case insensitive so that it will find JPG or jpg for example.
shopt -s nocaseglob
if [ ! -e *jpg && ! -e *gif && ! -e *png ]; then
echo "No images files found."
This isn't catching that no images are in the directory and the script just keeps running, giving tons of errors because the rest of the script relies on the existence of these image files.
I've been thinking over this for about an hour and tried several other things that gave the same result. What am I doing wrong?