• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 222
  • Last Modified:

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

0
us-pata
Asked:
us-pata
1 Solution
 
mahomeCommented:
you missed the semikolon (;) in row 2
0
 
us-pataAuthor Commented:
thx. so obvous, but im now to this so thx :)
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now