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 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: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
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



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

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

All times are GMT -5. The time now is 10:39 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