Trillex bash 1

From Teknologisk videncenter
Revision as of 12:01, 12 February 2009 by Trillex (talk | contribs) (New page: Category:LinuxCategory:H2Category:bash = Bash Scripts and Commands = == Bash Commands == == Bash Scripts == === Program for greeting users. Doesn't work === #!/bin/bash clear ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Bash Scripts and Commands

Bash Commands

Bash Scripts

Program for greeting users. Doesn't work

  1. !/bin/bash

clear echo -e "Welcome to my new bash-script" echo -e "=============================" echo -e "\n\n" # \n is the new-line command. So there will be two empty lines here echo -e "Rune Nordblom\nPRC-Data, Viborg\nDenmark" echo -e "The time is `date +%H:%M`." HOUR=`date +%H` MINUTE=`date +%M` if test $HOUR -le 7

 then
   echo -e "Please go to sleep."
     else if test $HOUR -le 8
       then
         echo -e "You are early."
           else if test ($HOUR -lt 11) -a ($MINUTE -lt 59)
             then
               echo -e "Good Morning."
                     else if test ($HOUR -lt 15) -a ($MINUTE -lt 59)
                       then
                         echo -e "Good afternoon."
                           else if test $HOUR -gt 16
                            then
                              echo -e "Please go home."     
                                fi
                           fi
                 fi
          fi

fi

Same as above but less advanced and working

  1. !/bin/bash

clear echo -e "Welcome to my new bash-script" echo -e "=============================" echo -e "\n\n" # \n is the new-line command. So there will be two empty lines here echo -e "Rune Nordblom\nPRC-Data, Viborg\nDenmark" echo -e "The time is `date +%H:%M`." HOUR=`date +%H` MINUTE=`date +%M` if test $HOUR -lt 7

 then echo -e "Please go to sleep."
 elif test $HOUR -lt 8
 then echo -e "You are early."
 elif test $HOUR -lt 11
 then echo -e "Good Morning."
 elif test $HOUR -lt 15
 then echo -e "Good afternoon."
 elif test $HOUR -gt 16
 then echo -e "Please go home."     

fi