Difference between revisions of "Bash examples"

From Teknologisk videncenter
Jump to: navigation, search
(New page: == if command == === Greetings === <source lang="bash"> #!/bin/bash #HOUR=`date +%H` HOUR=$1 if test $HOUR -le 7 then echo "You are early go home" else if test $HOUR -le 8 ...)
 
Line 1: Line 1:
 +
__TOC__
 
== if command ==
 
== if command ==
 
=== Greetings ===
 
=== Greetings ===

Revision as of 10:54, 12 February 2009

if command

Greetings

#!/bin/bash
#HOUR=`date +%H`
HOUR=$1
if test $HOUR -le 7
  then
    echo "You are early go home"
  else if test $HOUR -le 8
         then
           echo "You are early"
         else if test $HOUR -lt 12
                then
                  echo "Good morning, Vietnam"
                else if test $HOUR -lt 16
                       then
                         echo "Good evening"
                     fi
              fi
       fi
fi