As a programming language, shells can process variables in your scripts. Following are the three types of variables shell scripts you can work with:
Note If you have experience with other programming languages, you'll notice one difference with shell programming: variables are not typed in shell scripts. Conversely, if you learn shell scripting first and go on to other programming languages, you will need to learn how to identify variables as numbers, strings, or other data types that exist in that language. Assigning Values to VariablesDeclaring and initializing variables in bash is straightforward. To use a variable called lcount to count the number of iterations in a loop, type lcount=0. To store a string in a variable, just declare and identify: myname=mikemc If the string has embedded spaces, use quotes: myname="Michael McCallister" Accessing Variable ValuesAccess the value of a variable by prefixing the variable name with a dollar sign ($). To display your search path, for example, use $PATH. If the variable you want to access is var, use $var. To assign the value of var to the lcount variable, type lcount=$var |