Environmental variables are used to customize the behavior of programs and to pass information to them. In general, users do not set environmental variables from the command line, but rather have them set in their .profile or .cshrc files (examples of which are in Appendix 6). In trying to install, write, or run some new programs, you may need to modify your environmental variables from the command line, and so we show you how to do that in the examples.
Environmental variables differ from the related shell variables in that the former are passed along to all programs that execute, whereas shell variables are passed only to the shell or shell scripts (programs written in the shell's own language) in which they are defined. Shell variables with which you may be or become familiar include PATH and TERM. Others include TEXINPUTS, which tells the programs tex and latex where to find input files on your system, and MANPATH, which tells the man command where to find man pages.
To view a particular environmental variable, you issue the printenv command with the variable name as the argument. To view
all of your environmental variables, you use printenv with
no arguments:
printenv SHELL Your default shell. /bin/ksh $ printenv An SCO Unix example of _=/bin/printenv all variables. HZ=60 VISUAL=vi PATH=/bin:/usr/bin:/etc:/usr/dbin:/usr/ldbin LOGNAME=root MAIL=/usr/spool/mail/root MERGE_SPCL_MSG=Open Desktop DOS II_SYSTEM=/usr SHELL=/bin/sh HOME=/ TERM=xterm PWD=/usr/man TZ=EST5EDT
To change or set an environmental variable you use the export command. In sh or ksh you use an = sign, but
not in csh:
$ date We will change the behavior of date. Fri Nov 22 17:56:14 EST 1991 We get Eastern US time. $ TZ=CST6CDT Set Time Zone to cental time. $ export TZ We must export it to take effect. $ date Fri Nov 22 16:56:25 CST 1991 Now we get central time. $ export TZ=CST6CDT Set and export in one step. csh$ setenv TZ CST6CDT csh version, note no ``=.''