24.07.2018 Views

Bash-Beginners-Guide

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

fi<br />

;;<br />

*)<br />

echo -e "Guard: \"Don't forget the guide!\"\n"<br />

;;<br />

esac<br />

echo "Leaving..."<br />

echo -e "\a\a\aThanks for visiting the Zoo, hope to see you again soon!\n"<br />

michel ~/test> feed.sh apple camel<br />

Feeding apple to camel...<br />

Will you read this sign?! Don't feed the camels!<br />

Done feeding.<br />

Guard: "Buy the food that the Zoo provides at the entry, you ***"<br />

Guard: "You want to poison them, do you?"<br />

<strong>Bash</strong> <strong>Guide</strong> for <strong>Beginners</strong><br />

Leaving...<br />

Thanks for visiting the Zoo, hope to see you again soon!<br />

michel ~/test> feed.sh apple<br />

Usage of the feed script:<br />

./feed.sh food-on-menu animal-name<br />

More about escape characters can be found in Section 3.3.2. The following table gives an overview of<br />

sequences recognized by the echo command:<br />

Table 8-1. Escape sequences used by the echo command<br />

Sequence Meaning<br />

\a Alert (bell).<br />

\b Backspace.<br />

\c Suppress trailing newline.<br />

\e Escape.<br />

\f Form feed.<br />

\n Newline.<br />

\r Carriage return.<br />

\t Horizontal tab.<br />

\v Vertical tab.<br />

\\ Backslash.<br />

\0NNN<br />

\NNN<br />

The eight-bit character whose value is the octal value NNN (zero to three octal digits).<br />

The eight-bit character whose value is the octal value NNN (one to three octal digits).<br />

\xHH The eight-bit character whose value is the hexadecimal value (one or two hexadecimal digits).<br />

For more information about the printf command and the way it allows you to format output, see the <strong>Bash</strong> info<br />

pages. Keep in mind that there might be differences between different versions of <strong>Bash</strong>.<br />

Chapter 8. Writing interactive scripts 96

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

Saved successfully!

Ooh no, something went wrong!