Solved

if then else fi - error with folder exists

Posted on 2009-05-05
2
215 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
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
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…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

821 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