Add the following to the top of your script:
#! /bin/bash
In bash, ==
is the same as =
when used inside of single brackets. This is, however, not portable. So you should explicitly tell the shell to use bash as the script's interpreter by putting #! /bin/bash
at the top of the script.
Alternatively, do your string comparisons using =
. Note that the ==
operator behaves differently when used inside of double-brackets than when inside of single-brackets (see the link).