sample session involving “env” and “unset” commands

ABOUT env

env is a shell command for Unix and Unix-like operating systems. It is used to either print a list of environment variables or run another utility in an altered environment without having to modify the currently existing environment. Using env, variables may be added or removed, and existing variables may be changed by assigning new values to them.

In practice, env has another common use. It is often used by shell scripts to launch the correct interpreter. In this usage, the environment is typically not changed.

ABOUT unset

unset is a builtin command implemented by both the Bourne shell family (sh, ksh, bash, etc.) and the C shell family (csh, tcsh, etc.) of Unix command line shells. It unsets a shell variable, removing it from memory and the shell's exported environment. It is implemented as a shell builtin, because it directly manipulates the internals of the shell.[2][3]

Read-only shell variables cannot be unset. If one tries to unset a read-only variable, the unset command will print an error message and return a non-zero exit code.

A TYPICAL SHELL SESSION
[bash]
$ls -l
total 0
-rw-r–r– 1 jeffrin jeffrin 0 Jan 27 00:13 hello
-rw-r–r– 1 jeffrin jeffrin 0 Jan 27 00:14 world
$pwd
/home/jeffrin/sample
$env -i HOME=/home/jeffrin `cd`
HOME=/home/jeffrin
$pwd
/home/jeffrin/sample
$ls
hello world
$env -i bash
jeffrin@debian:/home/jeffrin/sample$ echo $TERM
dumb
jeffrin@debian:/home/jeffrin/sample$ echo $PS1
${debian_chroot:+($debian_chroot)}\u@\h:\w\$
jeffrin@debian:/home/jeffrin/sample$ export PS1=>
bash: syntax error near unexpected token `newline’
jeffrin@debian:/home/jeffrin/sample$ export PS1=">"
>unset $PS1
bash: unset: `>’: not a valid identifier
>unset PS1
export PS1=$
$
[/bash]
LINKS
https://en.wikipedia.org/wiki/Env
https://en.wikipedia.org/wiki/Environment_variable#unset_command