How to check if input is incorrect in bash? -
this question has answer here:
i trying write bash script takes data users , display entered information them. take date , time using following:
echo "enter day:" read day echo "enter time (hour):" read hour if [["$hour" -gt 24 || "$hour" -lt 1]] echo "wrong data" echo "enter time (hour):" read hour fi
when run following enter:
./file1.sh: line 5: [[27: command not found ./file1.sh: line 5: 27: command not found
27 number entered hour.
you need space after [[
, before ]]
.
Comments
Post a Comment