I want to write a greeting script. What I have so far:
if [ "$HOUR" -lt 12 ]; then
echo " Good Morning Mohamed"
elif [ "$HOUR" -ge 12 ] && [ "$HOUR" -lt 16 ]; then
echo " Good Afternoon Jama."
elif [ "$HOUR" -ge 16 ]; then
echo " Good Evening Jama."
fi
This give me an error
integer expression expected
How can I fix this?
HOURis the empty string. See the duplicate.HOUR. It's either empty or a string, but it's impossible to tell without the rest of your script. If this is your complete script, then it's obviously the empty string.HOURand want the code to still work, you can useif (( HOUR > 12 )); then ...construct. Look at this post for more details: stackoverflow.com/a/8552128/6862601