I am new to Gnu/Linux and bash, and I am trying, unsuccessfully, to write a simple bash script to test if
date +%H is within a predefined range of hours.
hour='date +%H' if [[ $hour -ge 12 ]] || [[ $hour -lt 19 ]] then echo "Good afternoon!"
Trying to isolate a line to this results in "integer expression expected":
test $hour -ge 12
It feels like I'm missing something simple to either have $hour return as integer or just handle it as a string.
Edit: Here's the completed script, any necessary improvements on the basic level?
!#/bin/bash name=$(whoami) hour=$(date +%H) if [ $hour -lt 5 ] || [ $hour -ge 19 ] then xmessage -center "Good evening $name!" elif [ $hour -ge 5 ] && [ $hour -lt 12 ] then xmessage -center "Good morning $name!" else xmessage -center "Good afternoon $name!" fi