Interview Prep/Shell Scripting/Troubleshooting: syntax, parsing and interpreter errors

`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.

All Shell Scripting questions Roadmap: Shell scripting (Bash)

More on Troubleshooting: syntax, parsing and interpreter errors