env

From NetBSD Wiki

Jump to: navigation, search

The env(1) command can be used in two different ways: print all environment variables or execute a specified command.

Contents

Print variables

When executed without any arguments, env will print a list of all currently defined environment variables, and their values.

% env
SHELL=/usr/pkg/bin/bash
TERM=xterm
WINDOWID=23068686
USER=testuser
TERMCAP=xterm|vs100|xterm terminal emulator (X Window System):am:bs:km:mi:ms:ut:xn:co#80:it#8:li#24:Co#8:pa#64:AB=\E[4%dm:AF=\E[3%dm:op=\E[m:@1=\EOE:@7=\EOF:@8=\EOM:k;=\E[21~:ac=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~:AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:DO=\E[%dB:IC=\E[%d@:K1=\EOw:K2=\EOy:K3=\EOu:K4=\EOq:K5=\EOs:LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:ae=^O:al=\E[L:as=^N:bl=^G:bt=\E[Z:cd=\E[J:ce=\E[K:cl=\E[H\E[2J:cm=\E[%i%d;%dH:cr=^M:cs=\E[%i%d;%dr:ct=\E[3g:dc=\E[P:dl=\E[M:do=^J:eA=\E(B\E)0:ec=\E[%dX:ei=\E[4l:ho=\E[H:im=\E[4h:is=\E[m\E7\E[r\E[?7h\E[?1;3;4;6l\E[4l\E8\E>:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:k5=\E[15~:k6=\E[17~:k7=\E[18~:k8=\E[19~:k9=\E[20~:kD=\E[3~:kI=\E[2~:kN=\E[6~:kP=\E[5~:kd=\EOB:ke=\E[?1l\E>:kh=\EOH:kl=\EOD:kr=\EOC:ks=\E[?1h\E=:ku=\EOA:le=^H:md=\E[1m:me=\E[m:mr=\E[7m:nd=\E[C:rc=\E8:sc=\E7:se=\E[m:sf=^J:so=\E[7m:sr=\EM:st=\EH:ta=^I:te=\E[2J\E[?47l\E8:ti=\E7\E[?47h:ue=\E[m:up=\E[A:us=\E[4m:ve=\E[?25h:vi=\E[?25l:vs=\E[?25h::ZZ=0x8120000:kb=\010:
PAGER=less
PATH=/home/testuser/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/pkg/bin:/usr/pkg/sbin:/usr/games:/usr/local/bin:/usr/local/sbin
PWD=/home/testuser
EDITOR=vi
PS1=\033[32m[\u:\w]\033[0m# 
HOME=/home/testuser
SHLVL=2
LOGNAME=testuser
DISPLAY=:0.0
_=/usr/bin/env

Execute command

When env is invoked with arguments, the first is used as the command to execute, and the rest are arguments to that command. Special options in the form name=value can be spcified to change the environment for the executed command.

% ls
file1 file2 file3 file4 file5 file6 file7 file8
& env COLUMNS=40 ls
file1 file3 file5 file7
file2 file4 file6 file8

Shebangs

The env command is frequently used in shebangs, so that a script will work wherever the interpreter is located.

Example:

#!/usr/bin/env perl
print "Hello\n"

See also

Retrieved from "http://wiki.netbsd.se/env"
Personal tools