27.08.2015 Views

Advanced Bash−Scripting Guide

Advanced Bash-Scripting Guide - Nicku.org

Advanced Bash-Scripting Guide - Nicku.org

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Advanced</strong> <strong>Bash−Scripting</strong> <strong>Guide</strong><br />

tput sgr0<br />

echo "ones, Mildred"<br />

echo −en '\E[47;32m'"\033[1mS\033[0m"<br />

tput sgr0<br />

echo "mith, Julie"<br />

echo −en '\E[47;31m'"\033[1mZ\033[0m"<br />

tput sgr0<br />

echo "ane, Morris"<br />

echo<br />

# Green<br />

# Red<br />

read person<br />

case "$person" in<br />

# Note variable is quoted.<br />

"E" | "e" )<br />

# Accept upper or lowercase input.<br />

echo<br />

echo "Roland Evans"<br />

echo "4321 Floppy Dr."<br />

echo "Hardscrabble, CO 80753"<br />

echo "(303) 734−9874"<br />

echo "(303) 734−9892 fax"<br />

echo "revans@zzy.net"<br />

echo "Business partner & old friend"<br />

;;<br />

"J" | "j" )<br />

echo<br />

echo "Mildred Jones"<br />

echo "249 E. 7th St., Apt. 19"<br />

echo "New York, NY 10009"<br />

echo "(212) 533−2814"<br />

echo "(212) 533−9972 fax"<br />

echo "milliej@loisaida.com"<br />

echo "Girlfriend"<br />

echo "Birthday: Feb. 11"<br />

;;<br />

# Add info for Smith & Zane later.<br />

* )<br />

# Default option.<br />

# Empty input (hitting RETURN) fits here, too.<br />

echo<br />

echo "Not yet in database."<br />

;;<br />

esac<br />

tput sgr0<br />

# Reset colors to "normal."<br />

echo<br />

exit 0<br />

The simplest, and perhaps most useful ANSI escape sequence is bold text, \033[1m ... \033[0m. The \033<br />

represents an escape, the "[1" turns on the bold attribute, while the "[0" switches it off. The "m" terminates<br />

each term of the escape sequence.<br />

Chapter 34. Miscellany 343

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!