| 1 | #!/bin/bash |
| 2 | # ex30a.sh: "Colorized" version of ex30.sh. |
| 3 | # Crude address database |
| 4 | |
| 5 | |
| 6 | clear # Clear the screen. |
| 7 | |
| 8 | echo -n " " |
| 9 | echo -e '\E[37;44m'"\033[1mContact List\033[0m" |
| 10 | # White on blue background |
| 11 | echo; echo |
| 12 | echo -e "\033[1mChoose one of the following persons:\033[0m" |
| 13 | # Bold |
| 14 | tput sgr0 # Reset attributes. |
| 15 | echo "(Enter only the first letter of name.)" |
| 16 | echo |
| 17 | echo -en '\E[47;34m'"\033[1mE\033[0m" # Blue |
| 18 | tput sgr0 # Reset colors to "normal." |
| 19 | echo "vans, Roland" # "[E]vans, Roland" |
| 20 | echo -en '\E[47;35m'"\033[1mJ\033[0m" # Magenta |
| 21 | tput sgr0 |
| 22 | echo "ambalaya, Mildred" |
| 23 | echo -en '\E[47;32m'"\033[1mS\033[0m" # Green |
| 24 | tput sgr0 |
| 25 | echo "mith, Julie" |
| 26 | echo -en '\E[47;31m'"\033[1mZ\033[0m" # Red |
| 27 | tput sgr0 |
| 28 | echo "ane, Morris" |
| 29 | echo |
| 30 | |
| 31 | read person |
| 32 | |
| 33 | case "$person" in |
| 34 | # Note variable is quoted. |
| 35 | |
| 36 | "E" | "e" ) |
| 37 | # Accept upper or lowercase input. |
| 38 | echo |
| 39 | echo "Roland Evans" |
| 40 | echo "4321 Flash Dr." |
| 41 | echo "Hardscrabble, CO 80753" |
| 42 | echo "(303) 734-9874" |
| 43 | echo "(303) 734-9892 fax" |
| 44 | echo "[email protected]" |
| 45 | echo "Business partner & old friend" |
| 46 | ;; |
| 47 | |
| 48 | "J" | "j" ) |
| 49 | echo |
| 50 | echo "Mildred Jambalaya" |
| 51 | echo "249 E. 7th St., Apt. 19" |
| 52 | echo "New York, NY 10009" |
| 53 | echo "(212) 533-2814" |
| 54 | echo "(212) 533-9972 fax" |
| 55 | echo "[email protected]" |
| 56 | echo "Girlfriend" |
| 57 | echo "Birthday: Feb. 11" |
| 58 | ;; |
| 59 | |
| 60 | # Add info for Smith & Zane later. |
| 61 | |
| 62 | * ) |
| 63 | # Default option. |
| 64 | # Empty input (hitting RETURN) fits here, too. |
| 65 | echo |
| 66 | echo "Not yet in database." |
| 67 | ;; |
| 68 | |
| 69 | esac |
| 70 | |
| 71 | tput sgr0 # Reset colors to "normal." |
| 72 | |
| 73 | echo |
| 74 | |
| 75 | exit 0 |