Link to home
Start Free TrialLog in
Avatar of us-pata
us-pata

asked on

if then else fi - error with folder exists

My script causes error:

without argument
# ./scriptname
#: line 9: syntax error near unexpected token `else'
#: line 9: `else'

with argument i get the same


anyone know what im doing wrong?
# $1 = wanted username
if [ "$1" ] then
        if [ -d /home/$1 ]; then
                echo "User exists..."
        else
                echo "do stuff"
        fi
else
        echo "Missing"
fi

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of mahome
mahome
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of us-pata
us-pata

ASKER

thx. so obvous, but im now to this so thx :)