syntax error near unexpected token `else’

I wrote it this way at first, but I got an error

#!/bin/bash
filename=$1
if [ -e /home/xx/$filename ]
echo "exist"
else
echo "inexistence"
fi 

It turned out there was a then missing

#!/bin/bash
filename=$1
if [ -e /home/xx/$filename ]
then
echo "exist"
else
echo "inexistence"
fi 


It’s ok after modification!

Read More: