Take the 2-minute tour ×
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.

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

1 Answer 1

up vote 4 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

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.