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

 

相关文章:

  • 2022-12-23
  • 2021-06-30
  • 2021-12-07
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-05
  • 2022-01-10
  • 2021-05-28
  • 2021-09-29
相关资源
相似解决方案