I want to do a loop for all the images in a directory. The images doesn't have extension so I have to read the first bytes of the image to know its type. The loop should end up being something like.for file in *do    if [ file --mime-type -b ]    then        ***    fidone
How to check the file type in a script
shell script;files;file command
Using the case statement and command substitution : for file in *; do    case $(file --mime-type -b $file) in        image/*g)        ... ;;        text/plain)      ... ;;        application/xml) ... ;;        application/zip) ... ;;        *)               ... ;;    esacdoneCheck :http://mywiki.wooledge.org/BashFAQ/002http://mywiki.wooledge.org/CommandSubstitutionhttp://mywiki.wooledge.org/BashGuide/TestsAndConditionals#Choiceshttp://wiki.bash-hackers.org/syntax/ccmd/case EDITif you insist to don't use case but an if statement using bash :if [[ $(file --mime-type -b $file) == image/*g ]]; then...else...fi 