LinuxQuestions.org
Help answer threads with 0 replies.
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 12-10-2005, 10:18 PM   #1
Milosevic
LQ Newbie
 
Registered: Nov 2005
Posts: 19

Rep: Reputation: 0
Shell variables


Whats the difference between:

a=10

and

export a=10

Cheers, Milosevic.
 
Old 12-10-2005, 10:31 PM   #2
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
The two 'a' variables here will have different scope; the first is a local variable, the second is an environmental variable.

http://www.tldp.org/LDP/abs/html/othertypesv.html
 
Old 12-10-2005, 10:32 PM   #3
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
a=10 assigns the value "10" to the shell variable "a".

export "a=10" assigns the value ... and propagates that value to any child shells.

Use "export" whenever you want a variable to be accessible to any subshells of your script.

You can find more details here:
http://vertigo.hsrl.rutgers.edu/ug/shell_help.html

PS:
anomie and I apparently clicked "send" almost simultaneously (hence this edit). Lest there be an confusion - we're both saying pretty much the same thing.

Last edited by paulsm4; 12-10-2005 at 10:35 PM.
 
  


Reply


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
Sub shell environment variables tnine9 Programming 1 06-08-2004 01:27 PM
Why?? can not use variables with shell script Bassam Linux - General 9 01-27-2004 07:42 AM
Setting Shell variables tmoorman Linux - Software 6 11-19-2003 03:41 PM
Shell Variables. ducka Programming 5 09-03-2003 05:38 PM
Makefiles and shell variables Snabber Linux - Software 1 08-05-2003 11:23 PM


All times are GMT -5. The time now is 06:17 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration