如何解决脚本中的"unary operator expected"错误?



expr:语法错误
h2.sh:第13行:[:-gt:应为一元运算符

#!/bin/sh

FILE=merchant.xml
OLDTIME=3600
CURTIME=$date
FILETIME=($date -r File)
TIMEDIFF=$(expr $CURTIME - $FILETIME)

if ["$TIMEDIFF" -gt "$OLDTIME" ]; then
echo "File is older, do stuff here" | mail -s "hello" hardik.pahwa@guemstiger.de
fi

请在此处添加空格

if ["$TIMEDIFF" -gt "$OLDTIME" ]; then
^

它应该像

if [ "$TIMEDIFF" -gt "$OLDTIME" ]; then

相关内容

最新更新