Difference between revisions of "Trillex bash 1"
From Teknologisk videncenter
(New page: Category:LinuxCategory:H2Category:bash = Bash Scripts and Commands = == Bash Commands == == Bash Scripts == === Program for greeting users. Doesn't work === #!/bin/bash clear ...) |
|||
Line 5: | Line 5: | ||
=== Program for greeting users. Doesn't work === | === Program for greeting users. Doesn't work === | ||
− | #!/bin/bash | + | #!/bin/bash |
− | clear | + | clear |
− | echo -e "Welcome to my new bash-script" | + | echo -e "Welcome to my new bash-script" |
− | echo -e "=============================" | + | echo -e "=============================" |
− | echo -e "\n\n" # \n is the new-line command. So there will be two empty lines here | + | 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 "Rune Nordblom\nPRC-Data, Viborg\nDenmark" |
− | echo -e "The time is `date +%H:%M`." | + | echo -e "The time is `date +%H:%M`." |
− | HOUR=`date +%H` | + | HOUR=`date +%H` |
− | MINUTE=`date +%M` | + | MINUTE=`date +%M` |
− | if test $HOUR -le 7 | + | if test $HOUR -le 7 |
then | then | ||
echo -e "Please go to sleep." | echo -e "Please go to sleep." | ||
Line 33: | Line 33: | ||
fi | fi | ||
fi | fi | ||
− | fi | + | fi |
==== Same as above but less advanced and working ==== | ==== Same as above but less advanced and working ==== | ||
− | #!/bin/bash | + | #!/bin/bash |
− | clear | + | clear |
− | echo -e "Welcome to my new bash-script" | + | echo -e "Welcome to my new bash-script" |
− | echo -e "=============================" | + | echo -e "=============================" |
− | echo -e "\n\n" # \n is the new-line command. So there will be two empty lines here | + | 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 "Rune Nordblom\nPRC-Data, Viborg\nDenmark" |
− | echo -e "The time is `date +%H:%M`." | + | echo -e "The time is `date +%H:%M`." |
− | HOUR=`date +%H` | + | HOUR=`date +%H` |
− | MINUTE=`date +%M` | + | MINUTE=`date +%M` |
− | if test $HOUR -lt 7 | + | if test $HOUR -lt 7 |
then echo -e "Please go to sleep." | then echo -e "Please go to sleep." | ||
elif test $HOUR -lt 8 | elif test $HOUR -lt 8 | ||
Line 56: | Line 56: | ||
elif test $HOUR -gt 16 | elif test $HOUR -gt 16 | ||
then echo -e "Please go home." | then echo -e "Please go home." | ||
− | fi | + | fi |
Revision as of 11:02, 12 February 2009
Contents
Bash Scripts and Commands
Bash Commands
Bash Scripts
Program for greeting users. Doesn't work
#!/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
#!/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