| xawk.com - technical wisdom served up in little slices | xawk.com -- Tags -- Bash |
| ||||||||
xawk.com -- Tags -- Bash -- Bash - A Basic Greeting Program.
Bash - A Basic Greeting Program. This is a basic Bash shell program to greet you with short message based on the time of the day.
Save the script as greetings.sh. To run it, you would open a terminal session, change to directory where you saved the scripts, and enter the command as shown below.
Depending on the time of day, you should be greeted with Good Morning, Good Afternoon, or Good Evening. Date Tips The first line to get the hour will seem a little strange.
What is happening is that you are running the date command with the optional format specifier. The format is "date [OPTION]... [+FORMAT]" where date is the command and "%H" means format the results as an hour in 24 hour format. The result of the date command gets saved as the value of the variable hour.
Tags: Bash Share: Del.icio.us | Digg | Facebook | Google Bookmarks | Reddit | Technorati | Windows Live | Yahoo! My Web
|
|