LAB 45: THE case STATEMENT

 <  Day Day Up  >  

LAB 45: THE case STATEMENT

  1. Write a script timegreet that will do the following:

    1. Provide a comment section at the top of the script, with your name , the date, and the purpose of this program.

    2. Convert the following program using case statements:

        # The timegreet script by Ellie Quigley  you=$LOGNAME hour=`date  awk '{print substr(, 1, 2)}'` print "The time is: $(date)" if (( hour > 0 && $hour < 12 )) then      print "Good morning, $you!" elif (( hour == 12 )) then      print "Lunch time!" elif (( hour > 12 && $hour < 16 )) then      print "Good afternoon, $you!" else      print "Good night, $you!" fi 

  2. Rewrite the lookup script, replacing the if/elif construct with the case command. Add one more menu item:

     1) Add Entry 2) Delete Entry 3) Update Entry 4) View Entry 5) Exit 

 <  Day Day Up  >  


UNIX Shells by Example
UNIX Shells by Example (4th Edition)
ISBN: 013147572X
EAN: 2147483647
Year: 2004
Pages: 454
Authors: Ellie Quigley

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net