Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i want to check a path if exist or not before pass it as argument

share|improve this question
up vote 3 down vote accepted
if [ -d /tmp ]
    echo the directory exists
share|improve this answer
i execute if [ -d / $1 ] ; then echo the directory exists else echo the directory not exists fi .... but always the result is echo the directory not exists ....the command is root@host/>./ text.txt – Mohammad AL-Rawabdeh Oct 6 '10 at 10:01
you need ";" before "else", additional one before "fi" won't hurt either. You also have a space between "/" and "$1" – Hubert Kario Oct 6 '10 at 10:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.