jeudi 18 février 2016

Why does incorrectly using <> in an if in bash statement create a file?

I mistakenly used the <> not equal comparison to check two variables:

if [ "2.57" <> "5" ]
then
  echo "Banana"
fi

This is wrong, as I now know (-ne is used not <>).

But my question is why did it create an empty file called 5 (the second comparator)? I know that echo Hello > file will create it, but there is no echo here.

What causes this to happen?

Aucun commentaire:

Enregistrer un commentaire