LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-24-2005, 11:37 AM   #1
calutateo
Member
 
Registered: May 2004
Location: Spain
Distribution: SuSE9x
Posts: 40

Rep: Reputation: 15
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
 
Old 07-24-2005, 11:55 AM   #2
avarus
Member
 
Registered: Apr 2004
Location: Oxford, UK
Distribution: Ubuntu, Debian, various
Posts: 230
Blog Entries: 5

Rep: Reputation: 33
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
 
Old 07-24-2005, 12:56 PM   #3
calutateo
Member
 
Registered: May 2004
Location: Spain
Distribution: SuSE9x
Posts: 40

Original Poster
Rep: Reputation: 15
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
set Versus env Echo Kilo Linux - General 2 06-09-2009 02:56 AM
Cannot set LD_LIBRARY_PATH in .cshrc (able to set other env variables) senthilpr_in Linux - Newbie 4 02-26-2007 12:46 PM
How to test if an env variable is set King of Men Linux - Newbie 5 11-03-2005 04:39 AM
how do you set an env variable from within a csh script? BrianK Linux - General 3 05-26-2004 02:16 PM
where are the env variables set on boot? Pete Dogg Linux - Software 1 09-10-2003 02:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration