shell判断文件/目录是否存在

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 ];then
echo param error!
exit
fi # 判断目录是不是已经存在,如果不存在则创建,存在则输出“dir exist”
dirname=$
echo "the dir name is $dirname"
if [ ! -d $dirname ];then
mkdir $dirname
else
echo dir exist
fi
上一篇:彻底禁用Chrome的“请停用以开发者模式运行的扩展程序”提示


下一篇:迅为iTOP-4418开发板-Android5.1系统编译补充