Solved

if then else fi - error with folder exists

Posted on 2009-05-05
2
216 Views
Last Modified: 2013-12-26
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
Comment
Question by:us-pata
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Accepted Solution

by:
mahome earned 125 total points
ID: 24302537
you missed the semikolon (;) in row 2
0
 
LVL 1

Author Closing Comment

by:us-pata
ID: 31577924
thx. so obvous, but im now to this so thx :)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Apache LDAP Authentication 20 72
WMIC Output Formatting 1 84
Certificate Request CentOS/Apache 1 57
sed replace command 12 28
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question