A script prints `/bin/sh: 1: [[: not found` and then continues as if the test were false.
BeginnerTroubleshootingTroubleshooting: syntax, parsing and interpreter errors
Answer
Likely causes → The script runs under dash (Ubuntu's /bin/sh), which has no [[. It was started with sh script.sh, has a #!/bin/sh shebang, or runs from a cron line or Dockerfile RUN (which uses /bin/sh -c).
Diagnose →
head -1 script.sh; ls -l /bin/sh
grep -n 'sh ' /etc/cron.d/* Dockerfile 2>/dev/null
Fix → Use #!/usr/bin/env bash and run it as ./script.sh or bash script.sh; in a Dockerfile use SHELL ["/bin/bash", "-o", "pipefail", "-c"]. Or rewrite the test in POSIX form with [ ] or case.
Prevent → Lint with ShellCheck; it warns when the shebang is sh and the code uses [[ (SC3010).
More on Troubleshooting: syntax, parsing and interpreter errors
`./deploy.sh` fails with `bash: ./deploy.sh: /bin/bash^M: bad interpreter: No such file or directory` (or, on Bash 5.2, `cannot execute: required file not found`).Beginner`bash: ./backup.sh: Permission denied` right after cloning the repo.Beginner`deploy.sh: line 14: syntax error near unexpected token `fi'`Beginner`install.sh: line 87: syntax error: unexpected end of file`Beginner`warning: here-document at line 12 delimited by end-of-file (wanted `EOF')` and the rest of the script never runs.Beginner`bash: [: missing `]'`Beginner