#!/bin/bash directory="/path/to/directory" if [ $(ls -A $directory) ]; then echo "有文件" # 执行指定shell脚本 sh /path/to/script.sh else echo "没有文件" fi
#!/bin/bash directory="/path/to/directory"if [ "$(ls -A $directory)" ]; thenecho"有文件"# 执行指定shell脚本 sh /path/to/script.sh elseecho"没有文件"fi 标签:文件,shell,包含,sh,文件夹,directory,path,echo From: https://www.cnblogs.com/xiaohanxqh/p/17148598.html