Shell line 7: [14: command not found [duplicate]

2019-03-07 11:20发布

This question already has an answer here:

I don't know what is the problem to fix Here is the code:

#!/bin/sh
while true
do
HOUR=$(date '+%H')
TARGET=16
echo $HOUR
if [$HOUR -gt $TARGET];
then
mail -s "IP" "example@hotmail.com" <<EOF
Global_IP=$(curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//')
EOF
echo "Sent"
fi
echo "Waiting..."
sleep 3600
echo "Done waiting"
done

Please help!

1条回答
唯我独甜
2楼-- · 2019-03-07 11:34

You have to add blanks after [ and before ]:

if [ $HOUR -gt $TARGET ];
查看更多
登录 后发表回答