`deploy.sh: line 14: syntax error near unexpected token `fi'`
BeginnerTroubleshootingTroubleshooting: syntax, parsing and interpreter errors
Answer
Likely causes → The if above is malformed: missing then, missing ; before then on the same line, an empty then block, or a missing space inside [ ].
Diagnose →
bash -n deploy.sh # syntax check without running
sed -n '8,14p' deploy.sh
Typical culprits: if [ -f "$f" ] then, if [ -f "$f"]; then (no space before ]), or a then followed directly by fi with no commands.
Fix → if [[ -f $f ]]; then ... fi. An empty branch needs a command: then :.
Prevent → Run bash -n and ShellCheck in pre-commit; use an editor with shell syntax highlighting.
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`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 `]'`BeginnerA script prints `/bin/sh: 1: [[: not found` and then continues as if the test were false.Beginner