Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Environment variables can be shown with env; but, some are not shown. For example...

echo $EUID might produce as result of 1000 yet env | grep EUID produces no result.

What is this type of variable? A read-only environment variable?

Do all shells set the same variables by some convention?

How does one go about listing these hidden variables?

share|improve this question
2  
see also: unix.stackexchange.com/questions/3510/… – lesmana Mar 17 '13 at 17:52
    
Not all shell variables are environment variables, only those that are marked for export by, e.g., the export command. – chepner Mar 24 '13 at 3:18
up vote 5 down vote accepted

The set command shows all variables (and functions), not just the exported ones, so

set | grep EUID

will show you the desired value. This command should show all the non-exported variables:

comm -23 <(set | grep '^[^=[:space:]]\+=' | sort) <(env | sort)
share|improve this answer
    
Unfortunately 'set' can add quotes while 'env' does not as such this will list some variables (often very long ones), which are actually exported environment variables. – user326853 Jun 8 at 0:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.