首页 > 系统服务 > 详细

shell file/dir exist

时间:2018-08-15 19:53:34      阅读:301      评论:0      收藏:0      [点我收藏+]

https://www.cnblogs.com/37yan/p/6962563.html

 

caution!!! if should be end with fi

 

caution!!! there should be a space between [ and ! , also between 1 and ]

if [ ! $# -eq 1  ];then
#!/bin/bash
# 判断传入的参数的个数是不是一个
if [ ! $# -eq 1  ];then
  echo param error!
  exit 1
fi

# 判断目录是不是已经存在,如果不存在则创建,存在则输出“dir exist” 
dirname=$1
echo "the dir name is $dirname"
if [ ! -d $dirname  ];then
  mkdir $dirname
else
  echo dir exist
fi

 

shell file/dir exist

原文:https://www.cnblogs.com/zealousness/p/9483523.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!