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

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -