Variables in Shell Scripts

 < Day Day Up > 

Previously in this chapter, it was stated that Linux shell scripts are very similar to many traditional programming languages, such as C++ and BASIC. In any programming language you will need to store data temporarily. For example, if you want a script to divide two numbers and display the answer, you will need to store those two numbers and the answer. To process information, data must be kept in the computer’s RAM memory. RAM memory is divided into small segments, and each segment has a unique number called memory location/address, which is used to hold data. We could designate a specific memory address to store our data, but that would be an absolutely monumental task. You would have to memorize the thousands of possible memory addresses. You also would have to realize that not all the addresses available now will be available the next time you run the script. Fortunately, this problem was solved a long time ago by the creators of the modern programming languages. In your code you declare some name as a representation for a place in memory. The specific address that your name refers to is determined by the system itself; you don’t have to do that. This name for a specific location in memory is called a variable because its contents can vary. You can change what is stored there. A variable is a name for a location in memory used to store data.

In the Linux shell you have two types of variables: system variables and user- defined variables, also called UDVs. System variables are created and maintained by Linux itself. This type of variable is always written in all capital letters, so they are easy to recognize. The second type of variable, the user-defined variable, is created and maintained by the user. This type of variable is always written in all lowercase letters.

 < Day Day Up > 

Moving From Windows to Linux
Moving From Windows To Linux (Charles River Media Networking/Security)
ISBN: 1584502800
EAN: 2147483647
Year: 2004
Pages: 247
Authors: Chuck Easttom

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: