file="config.yaml" if [ ! -f "$file" ] # not exist then echo "file not exist" # do something # touch "$file" else echo "file exist" fi判断文件是否为空
如果文件为空,则一直下载,直到文件不为空为止。
file="config.yaml" while [ ! -s "$file" ] # -s if file empty do echo "redownloading...." wget -O config.yaml "https://www.thismiao.xyz/link/21fQ=info" done主代码
cd /home/vm/software/clash file="config.yaml" rm "$file" if [ ! -f "$file" ] # not exist then echo "download the config file" while [ ! -s "$file" ] # -s if file empty do echo "redownloading...." wget -O config.yaml "https://www.thismiao.xyz/link/2?cl&log-level=info" done fi ./clash -d .
参考文章:
- shell中的循环语句、判断语句实例
- 判断文件是否存在的shell脚本代码
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)