LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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 09-28-2008, 01:26 AM   #1
paragkalra
Member
 
Registered: Sep 2006
Location: Nagpur, Maharashtra, India
Distribution: Debian, Ubuntu, Redhat, Fedora, SLES, OpenSUSE, FreeBSD, Mac OS X
Posts: 221

Rep: Reputation: 31
Silly Shell Question


Quote:
Local Variable Definition: A variable declared as local is one that is visible only within the block of code in which it appears.
Quote:
Global Variable Definition: Global environment variables are visible from the shell session, and any child processes that the shell spawns.
Keeping these definitions in mind what is the difference between global variables displayed by "evn" command and local variables displayed by "set" command?
 
Old 09-28-2008, 03:27 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 26,991
Blog Entries: 54

Rep: Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743
Quote:
Originally Posted by paragkalra View Post
Keeping these definitions in mind what is the difference between global variables displayed by "evn" command and local variables displayed by "set" command?
You could ask yourself what the origin of 'env' and 'set' is? With the distinction that "local" in such cases usually refers to functions, subshells and such, in a generic GNU/Linux layout 'env' is a binary part of coreutils (which) and shows vars set for or by the login shell and what gets sourced automagically. Some vars of which are immutable by generic unprivileged users and whose scope is systemwide (UID, locale settings, etc). In a shell like Bash 'set' is a built-in (type) displaying variables inherited from the login shell plus those the shell emits, needs, recognises or understands them itself from sourcing.

I'm sure somebody else has got a more clean definition.
 
Old 09-28-2008, 11:31 AM   #3
john test
Member
 
Registered: Jul 2008
Distribution: ubuntu 9.10
Posts: 527
Blog Entries: 1

Rep: Reputation: 35
unSpawn has it right, but just to look at the difference you could try opening two xterm windows and doing "set" in one and "env" in the other.
Side by side comparison will show the inherited variables and the additional info in "set"
 
  


Reply

Tags
global, local, paragkalra, variables


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
silly question bruj3w Slackware 3 08-20-2004 12:51 PM
Silly question Anathema25476 Linux - Software 3 02-11-2004 05:06 AM
A silly question?? JIV Linux - Newbie 1 10-31-2003 01:01 AM
Silly ls question R4z0r Linux - Newbie 3 07-15-2003 06:08 AM
silly question ramu_ak Linux - General 2 03-24-2003 09:45 AM


All times are GMT -5. The time now is 08:45 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration