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

2019-03-07 11:39发布

问题:

This question already has an answer here:

  • shell script command not found when comparing string 1 answer

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:

You have to add blanks after [ and before ]:

if [ $HOUR -gt $TARGET ];