Front | Info | Lists | Newsfeeds | Study Guide | What is BSD? |
|
This is the BSDA Study Guide Book written via a wiki collaboration. This is a work in progress. You may contribute to or discuss this specific page at http://bsdwiki.reedmedia.net/wiki/Recognize__44___view_and_modify_environmental_variables.html. Recognize, view and modify environment variablesConceptBe able to view and modify environment variables both temporarily and permanently for each of the default shells found on BSD systems. IntroductionEnvironment variables are key-value pairs available to executing processes. By way of environment variables, users (and other processes) can pass data to new processes. Both keys and values can only be strings, and both are usually case sensitive. In shell scripts interpreted by Some environment variables need only to be set, without regards for their content (one example is the Most shells have their own internal variables, which should not be confused with global environment variables as they are not passed to newly started processes. Different shells have different commands for manipulating environment variables. Read more about their syntax in the appropriate manual pages. sh, bashInternal shell variables can be set simply by issuing a statement like " Shell variables are only valid within a shell process instance (spawned subshells will not contain their parent's internal variables). In order to just set an environment variable with empty content, use the form " csh, tcshInternal shell variables can be set and inspected with the To set an environment variable to empty content, use Common environment variablesThere are environment variables which have well defined meanings for a Unix process. Some of them are:
ExamplesAutomatically set and export an environment variable called "VEGETABLE" to "Carrot", in bash:
Create an environment variable called "VEHICLE" containing the string "Truck", in tcsh:
List environment variables, in tcsh:
Note that (ba)sh uses "=" to set enviroment variables, and (t)csh doesn't. Practice Exercises
More informationenv(1), sh(1), csh(1), tcsh(1), environ(7)
|