问题描述 今天要写一个记录日志的shell,先判断日志文件是否存在,结果运行的时候报错了 ./log.sh: line 10: [: missing `]' 原因分析 在linux的判断符号[]中,必须注意中括号的两端要有空格符来分隔 解决方案 错误代码 if [ ! -f /var/log/shell/${date}/log_${date}.log] 更新后代码 if [ ! -f /var/log/shell/${date}/log_${date}.log ]