If your script is executable and you are executing it like ./getconfig.sh
, the first line of your script needs to be:
#!/bin/bash
Without that shebang line, your script will be interpreted by sh
which doesn't understand [[
in if
statements.
Otherwise, you should run your script like bash getconfig.sh
, not sh getconfig.sh
. Even if your default shell is bash, scripts run with sh
will use a reduced set of bash's features, in order to be more compliant with the POSIX standard. [[
is one of the features that is disabled.