Prev | Current Page 202 | Next

Christopher Negus

"Linux Bible, 2008 Edition: Boot up to Ubuntu, Fedora, KNOPPIX, Debian, openSUSE, and 11 Other Distributions"

(The bash man page lists
variables already in use.)
To set an environment variable temporarily, you can simply type a variable name and assign it to a
value. Here??™s an example:
$ AB=/usr/dog/contagious/ringbearer/grind ; export AB
This example causes a long directory path to be assigned to the AB variable. The export AB command
says to export the value to the shell so that it can be propagated to other shells you may
open. With AB set, you go to the directory by typing the following:
$ cd $AB
The problem with setting environment variables in this way is that as soon as you exit the shell in
which you set the variable, the setting is lost. To set variables permanently, add variable settings to
a bash configuration file, as described later in this section.
Another option to add the settings to the bash configuration file is to create an executable
script file that contains these settings. This is useful when you don??™t use the settings
all the time, but need to use them occasionally. They are there only for the life of the session
after the script file has run.
NOTE
62
Linux First Steps Part I
If you want to have other text right up against the output from an environment variable, you can
surround the variable in braces. This protects the variable name from being misunderstood.


Pages:
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214