开发者

Shell Script for checking existence of a directory

if[-d /abmusr06/abm/u开发者_开发知识库sers/dywrk01/run_time];
   then
     echo "Pack installation Failed"
     exit(1)
fi

This the above code fine?


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.


if [ -d "directory" ];then
 ....
fi
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜