3.1. VariablesI'm not going to try to explain all the details of Bash scripting in a section of this HOWTO, just the details pertaining to prompts. If you want to know more about shell programming and Bash in general, I highly recommend Learning the Bash Shell by Cameron Newham and Bill Rosenblatt (O'Reilly, 1998). Oddly, my copy of this book is quite frayed. Again, I'm going to assume that you know a fair bit about Bash already. You can skip this section if you're only looking for the basics, but remember it and refer back if you proceed much farther. Variables in Bash are assigned much as they are in any programming language:
Quotes are only needed in an assignment if a space (or special character, discussed shortly) is a part of the variable. Variables are referenced slightly differently than they are assigned:
A variable can be referred to as $bar or ${bar}. The braces are useful when it is unclear what is being referenced: if I write $barley do I mean ${bar}ley or ${barley}? Note also that referencing a value that hasn't been assigned doesn't generate an error, instead returning nothing. Linux HOWTO full list |
|
This document, LDP HOWTO-INDEX, is copyrighted (c) 1995 - 2002 by Tim Bynum, Guylhem Aznar, Joshua Drake and Greg Ferguson. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is available at http://www.gnu.org/copyleft/fdl.html. If you have questions, please contact the LDP.
Web Design Copyright © 1999-2003. Chrisranjana Software Solutions Pvt Ltd. syndicate rss feed |