My Personal Notes
time of the In this example, we have declared condition., to the user.“Good Morning”, “Good Afternoon”, “Good Evening” and “Good Night”. Depending on the #!/bin/bash hour=$(date +%H) if [ $hour -lt 12 ] then greet="Good Morning" elif [ $hour -le 16 ] then greet="Good Afternoon" elif [ $hour -lt 20 ] then greet="Good Evening" else greet="Good Night" fi echo "$greet"it satisfies the websites: Good morning, Good afternoon, Good Evening, or Good Night ‘greet'which is holding Example 2:the statement if Information obtained from system, it will print a new variable
Output :value of `date +%H`. The command “date +%H” returns the hour arrow_drop_uptime it gets less than equal less than 12
The variable “hour” will hold the
script displays “Good morning!”, “Good afternoon!”, “Good evening” or “Good night” based on the
echo "GOOD AFTERNOON WORLD" elif [ $hour -le 20 ] # if hour is Good Morning, # Good Afternoon, Good Evening $ and Good Night, according to $ system time. #!/bin/bash hour=`date +%H` if [ $hour -lt 12 ] # if hour is have .sh extension.The above shell to 16 then # Program to print system. The program will echo "GOOD EVENING WORLD" else echo "GOOD NIGHT WORLD" filess than equal
Example :in 24-hour format. The command “echo” will simply print