开发者

Shell Script for checking existence of a directory

开发者 https://www.devze.com 2023-01-19 05:35 出处:网络
if[-d /abmusr06/abm/u开发者_开发知识库sers/dywrk01/run_time]; then echo \"Pack installation Failed\"
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

精彩评论

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