CoolComputing Logo
Coupons/Deals  ·  New Promo Codes/Coupons  · May 22, 2018

BASH IF ELSE Example Plus Nested IF Example

Posted on Saturday, September 25, 2010 @ 06:20:51 PM CDT by David Yee [] [read 3291 times]

 
Tips: Linux/Unix world
Here is an example of the usage of an IF Else with a Nested IF for writing a script for BASH:

current_hour=$(date +"%H");

#if it is past midnight but not yet 6 AM
if [ $current_hour -ge 0 -a $current_hour -lt 6 ]
then
    echo "You are not in bed yet?"
else
    #if it is 6PM but not yet 8PM
    if [ $current_hour -ge 18 -a $current_hour -lt 20 ]
    then
         echo "Dinner time!"
     fi
fi

Here are some BASH if/then logic syntax in-depth examples and tutorial via video:





Please rate this article or post a brief review of BASH IF ELSE Example Plus Nested IF Example or comment on benchmark/performance, features, availability, price or anything else regarding BASH IF ELSE Example Plus Nested IF Example. Thanks!

BASH IF ELSE Example Plus Nested IF Example Rating: 2.4/5 (7 votes cast)

Your Name:
I have read and agreed to the Review Posting Agreement.
Review Title:
Comment/Review: