Parameters and Variables

This section describes parameters and variables.

User-Defined Variables

Any variable defined by a programmer is a user defined variable. User-defined variable names

  • Must start with letters

  • Can contain only letters or digits

  • Are often in capital letters to differentiate them from UNIX commands

Variables are assigned values using the assignment operator, =, as follows:

							VAR=value
						

Here, VAR is the name of the variable and value is the value you want to assign to it.

Variables are unset using the unset command as follows:

unset var1 ... varN
						

Here var1varN are the names of the variables to unset.

Variable Substitution

The value stored in a variable can be accessed using the $ operator as follows:

$VAR
							

Here VAR is the ...

Get Sams Teach Yourself Shell Programming in 24 Hours, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.