For
example, if you want to add a command name to the AB variable shown earlier, you can type the
following:
$ echo ${AB}/adventure
/usr/dog/contagious/ringbearer/grind/adventure
Remember that you must export the variable so that it can be picked up by other shell commands.
You must add the export line to a shell configuration file for it to take effect the next time you log
in. The export command is fairly flexible. Instead of running the export command after you set
the variable, you can do it all in one step, as follows:
$ export XYZ=/home/xyz/bin
You can override the value of any environment variable. This can be temporary, by simply typing
the new value, or you can add the new export line to your $HOME/.bashrc file. One useful variable
to update is PATH:
$ export PATH=$PATH:/home/xyz/bin
In this example, the /home/xyz/bin directory is added to the PATH, a useful technique if you
want to run a bunch of commands from a directory that is not normally in your PATH, without
typing the full or relative path each time.
If you decide that you no longer want a variable to be set, you can use the unset command to
erase its value. For example, you can type unset XYZ, which causes XYZ to have no value set.
(Remember to remove the export from the $HOME/.
Pages:
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215