Understanding Scripting Variables
I’ve already told you a bit about scripting variables, and you’ve already seen them in use. But, there’s a bit more to the story.
Creating and Deleting Variables
As you’ve already seen, it’s sometimes either necessary or more convenient to define variables in your scripts. You can also define, view, and unset variables from the command-line. Here’s an example:
[donnie@fedora ~]$ car=Ford
[donnie@fedora ~]$ echo $car
Ford
[donnie@fedora ~]$ unset car
[donnie@fedora ~]$ echo $car
[donnie@fedora ~]$
Here, I’ve defined the variable car
, and set its value to Ford
. The first echo
command shows the assigned value. The second echo
command verifies that I’ve successfully cleared the variable with unset
.
Understanding Variables and Shell Levels
When you place a shebang line, such as #!/bin/bash
or #!/bin/sh
, at the start of your script, a new non-interactive child shell will be...