The problem described in the questioned has already been solved. I just wanted to share my experience here because the error message I got was the same, even if the reason and the solution was slightly different.
#!/bin/bash
echo "a"
if [ -f x.txt ]; then \
echo "b" \
fi;
echo "c"
This script produced the same error message and the solution was to add the missing semicolon to the end of the echo "b" line:
#!/bin/bash
echo "a"
if [ -f x.txt ]; then \
echo "b" ; \
fi;
echo "c"
The direct reason was the same as it was in the original question. The if didn't have its closing pair fi. The reason, however, was that the fi line blended into the previous line, due to the missing ; semicolon.
elifkeyword in bash (help iffor more info).bashcould not produce a better error.fiwas missingmissing fiin addition of line no in this case.