Env
From Wikipedia, the free encyclopedia
- The correct title of this article is env. The initial letter is shown capitalized due to technical restrictions.
- For other uses of the three-letter term 'env' see Env (disambiguation)
env is a shell utility for Unix-like operating systems (including Linux). It is used to either print a list of environment variables or run another utility in an altered environment. Using env, variables may be added or removed, and the values of existing variables may be changed.
In practice, env has another common use. It is often used by scripts to launch the correct interpreter. In this usage, the environment is typically not changed.
[edit] Example
Here is the code of a very simple Python script:
#!/usr/bin/env python print "Hello World."
In this example, /usr/bin/env is the full path of the env command. The environment is not altered.
Note that it is possible to specify the interpreter without using env, by giving the full path of the python interpreter. A problem with that approach is that on different computer systems, the exact path may be different. By instead using env as in the example, the interpreter is searched for and located at the time the script is run. This makes the script more portable, but also increases the risk that the wrong interpreter is selected because it searches for a match in every directory on the executable search path.
[edit] External links
- Official GNU Env manual
- Linux man page on usr-share-man.org : run a program in a modified environment –
Unix command line programs and builtins (more) | |||
File and file system management: | cat | cd | chmod | chown | chgrp | cp | du | df | file | fsck | ln | ls | lsof | mkdir | mount | mv | pwd | rm | rmdir | split | touch | ||
Process management: | at | chroot | crontab | exit | kill | killall | nice | pgrep | pidof | pkill | ps | sleep | time | top | wait | watch | ||
User Management/Environment: | env | finger | id | mesg | passwd | su | sudo | uname | uptime | w | wall | who | whoami | write | ||
Text processing: | awk | comm | cut | ex | head | iconv | join | less | more | paste | sed | sort | tail | tr | uniq | wc | xargs | ||
Shell programming: | echo | expr | printf | unset | Printing: | lp |
Communications: inetd | netstat | ping | rlogin | traceroute |
Searching: find | grep | strings |
Miscellaneous: banner | bc | cal | man | size | yes |