Meaning of “[: too many arguments” error from if [] (square brackets)

I couldn’t find any one simple straightforward resource spelling out the meaning of and fix for the following BASH shell error, so I’m posting what I found after researching it.

The error:

-bash: [: too many arguments

Google-friendly version: bash open square bracket colon too many arguments.

Context: an if condition in single square brackets with a simple comparison operator like equals, greater than etc, for example:

VARIABLE=$(/some/command);
if [ $VARIABLE == 0 ]; then
  # some action
fi 

6 Answers
6

Leave a Comment