sh & export

Polytropon freebsd at edvax.de
Tue Jan 29 00:19:39 UTC 2013


On Mon, 28 Jan 2013 18:55:02 -0500, Fbsd8 wrote:
> I'm reading a script and i see a lot of exports.
> 
> Is there some command to display the exported environment?

Yes, sh's builtin "env" does this.



> The env command does not show them. Only see things made by setenv command.

It seems you're mixing shells here. The C Shell uses setenv
to set variables, printenv to list them. The systems's sh
uses export to set variables, and env to print them.

Example (with exported and non-exported variable:

	$ export ASDF=yxcvbnm
	$ env | grep ASDF
	ASDF=yxcvbnm

	$ JKL=qwertzuiop
	$ env | grep JKL
	$ echo $JKL
	qwertzuiop

And compare for the C shell:

	% setenv ASDF yxcvbnm
	% printenv | grep ASDF
	ASDF=yxcvbnm

	% set JKL=qwertzuiop
	% printenv | grep JKL
	% echo $JKL
	qwertzuiop

If you omit the "| grep" step, the full list will be printed.



-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...


More information about the freebsd-questions mailing list