tags:

views:

35

answers:

2
if[-d /abmusr06/abm/users/dywrk01/run_time];
   then
     echo "Pack installation Failed"
     exit(1)
fi

This the above code fine?

+3  A: 

Assuming this is Bourne Shell (/bin/sh):

if [ -d /abmusr06/abm/users/dywrk01/run_time ]
then
    echo "Pack installation Failed"
    exit 1
fi
  • Put spaces around the brackets: if [ -d. Think of [ as a (key)word - it needs to stand by itself. You wouldn't say ls-l, you say ls(space)-l.
  • Use exit 1, not exit(1).
  • The semicolons are unnecessary if everything is on separate lines.
  • The above seems to work in Cygwin for me.
Bert F
Think of `[` not as a keyword, but as a command (because that's what it is)
glenn jackman
A: 
if [ -d "directory" ];then
 ....
fi
ghostdog74
and also `exit 1`
jyzuz