Difference: PathsAndVariables (2 vs. 3)

Revision 32012-04-26 - goodmami

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Building and running code: Paths and Environment Variables

Line: 64 to 64
 [...]
sed 's/[\?.!,"]//g' < $textfile

Environment Variables

Changed:
<
<
Above, we exported a variable so it would be accessible to subsequent script calls. That was an example of creating an environment variable. There are a number of standard environment variables, such as PATH, HOME, USER, HOSTNAME, etc. PATH has a number of paths (delimited by colons) where executables (such as `ls`, `cat`, `vim`, `scp`, etc) are located. You can modify PATH, but if you clear it you will have trouble doing much of anything.
>
>
Above, we exported a variable so it would be accessible to subsequent script calls. That was an example of creating an environment variable. There are a number of standard environment variables, such as PATH, HOME, USER, HOSTNAME, etc. PATH has a number of paths (delimited by colons) where executables (such as `ls`, `cat`, `vim`, `scp`, etc) are located. You can modify PATH, but if you clear it you will have trouble doing much of anything. Some programs have their own standard environment variables. Java has JAVAHOME and CLASSPATH, and Python has PYTHONHOME and PYTHONPATH.
 
Changed:
<
<
Some programs have their own standard environment variables. Java has JAVAHOME and CLASSPATH, and Python has PYTHONHOME and PYTHONPATH.
>
>
You can see what environment variables are set with the `env` command:

~$ env
HOSTNAME=patas.ling.washington.edu
[...]
G_BROKEN_FILENAMES=1
_=/bin/env

If you only want to see the value of one variable, you can echo it:

~$ echo "$HOSTNAME"
patas.ling.washington.edu

`unset` is used to clear a variable (be careful, it completely clears the variable, rather than clearing only local changes):

~$ echo "$CLASSPATH"
:/opt/mysql-connector-java/mysql-connector-java-5.1.6-bin.jar:/opt/GNUstep/System/Library/Libraries/Java:/opt/GNUstep/Local/Library/Libraries/Java:/home2/goodmami/GNUstep/Library/Libraries/Java
~$ unset CLASSPATH
~$ echo "$CLASSPATH"

  If you modify an environment variable, it is valid within the current process. For instance, if you change it at the command line, it will be valid for any further commands you execute, but it won't be valid for other sessions (for instance if you log in to patas.ling.washington.edu in two or more simultaneous sessions). If you modify it within a script, it will be valid in that script and subsequent calls from it.
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback