使用shell判断文件夹中是否包含文件
#!/bin/bash directory="/path/to/directory" if [ $(ls -A $directory) ]; then echo "有文件" # 执行指定shell脚本 sh /path/to/script.sh else echo "没有文件" fi
directory="/path/to/directory"if [ "$(ls -A $directory)" ]; thenecho"有文件"# 执行指定shell脚本 sh /path/to/script.sh elseecho"没有文件"fi