LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   set or env? (https://www.linuxquestions.org/questions/linux-newbie-8/set-or-env-346244/)

calutateo 07-24-2005 11:37 AM

set or env?
 
Hi,

The commands set and env both deliver the environment variables and their values, however
Code:

set | wc -l
769
env | wc -l
81

What ist the difference between them?
Could somebody name a good tutorial with examples?

Regards, Carsten

avarus 07-24-2005 11:55 AM

Hi Carsten,

The difference is that 'set' is also reporting shell-local variables. These look the same from the point of view of the shell user, but are not passed on to the new process if you run a command. When you use the 'export' command you promote a shell variable to be an environment variable.

Environment variables are a fundametal feature of Linux, while shell variables are just a feature of the shell. To fully understand how environment variables work you really need to appreciate the fork/exec process model. I would direct you to the mighty Rute for some explanation:

http://www.icon.co.za/~psheer/book/node12.html.gz

TIM

calutateo 07-24-2005 12:56 PM

Tim,

Thank you very much for the excellent explanation. And thank you also for the Rute link. I read the Rute book more than 4 years ago, and I completely forgot about it. Great book.

Regards, Carsten


All times are GMT -5. The time now is 01:16 AM.