vendredi 29 juillet 2016

Bash "if" condition being executed no matter what

I'm new to bash scripting, and, while I know this is undoubtably a duplicate question, I can't figure out how to word it to search for it.

for i in $( ls); do
    FILETYPE=$( file -b $i )
    if [ "$FILETYPE"="Apple binary property list" ]; then
        echo $FILETYPE
    else 
        echo "nope"
    fi
done

I'm expecting this to ONLY print
"Apple binary property list"
when the statement succeeds and to ONLY print "nope" otherwise.

What's happening is that it's printing the filetype regardless of whether the statement succeeds or fails, and never prints "nope".

I know it's something simple, but can someone please tell me why it's printing anything other than "Apple binary property list" and "nope",
and what i can do to fix it?

Aucun commentaire:

Enregistrer un commentaire