LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 05-19-2009, 06:51 AM   #1
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Rep: Reputation: 55
where a variable is stored in linux


hi all...

If i declare a variable vech=bus in terminal then i will execute export vech...i want to know where this variable is stored......


can anyone please help me.....

thanks in advance
 
Old 05-19-2009, 07:21 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
They are stored in the memory allocated by a process. Environment variables are inherited by child processes and they are destroyed when the parent dies. What is the scope of this question?
 
Old 05-19-2009, 07:38 AM   #3
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Original Poster
Rep: Reputation: 55
i want to delete the variable declared...
 
Old 05-19-2009, 07:49 AM   #4
rikijpn
Member
 
Registered: Jun 2007
Location: Japan
Distribution: Debian lenny, DSL, Solaris 10
Posts: 157

Rep: Reputation: 33
use the unset command

You usually don't need to worry about shell variables (at least in the storage sense, for they are so tiny), but just in case; the "declare" command shows you all the variables in your shell, if you use autocompletion the list will be huge. And in order to delete a variable you can use the "unset" command.
More about unset here-> http://linux.about.com/library/cmd/blcmdln_unset.htm
 
Old 05-19-2009, 07:56 AM   #5
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Yes. unset should do the trick.
 
Old 05-19-2009, 09:27 AM   #6
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,051

Rep: Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852
^ does this do anything:
Code:
var=5555
echo $var
var=""
 
Old 05-19-2009, 09:44 AM   #7
rikijpn
Member
 
Registered: Jun 2007
Location: Japan
Distribution: Debian lenny, DSL, Solaris 10
Posts: 157

Rep: Reputation: 33
Quote:
Originally Posted by schneidz View Post
^ does this do anything:
Code:
var=5555
echo $var
var=""
Of course it does something, it declares a null string. If you do please "declare |grep var" the variable will still be there. This is very different from "deleting" the variable.
 
Old 05-19-2009, 10:22 AM   #8
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Original Poster
Rep: Reputation: 55
where this declare file is stored in the system ...
 
Old 05-19-2009, 11:02 AM   #9
rikijpn
Member
 
Registered: Jun 2007
Location: Japan
Distribution: Debian lenny, DSL, Solaris 10
Posts: 157

Rep: Reputation: 33
What do you mean by where? What kind of answer are you looking for? A variable (in your shell, as you described), is just stored in your shell environment (your memory).
 
Old 05-19-2009, 12:03 PM   #10
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,063

Rep: Reputation: 381Reputation: 381Reputation: 381Reputation: 381
Maybe he means in-disk.

These variables are not permanently stored anywhere. You need to declare them each time. However you can use the shell initialization files for that. For example, in bash you could use /etc/profile, ~/.bashrc, ~/.bash_profile and a few others depending on the concrete circumstance when you need that variable to be set. For bash, check the "INVOCATION" section of the bash man page to know more about these rc files.
 
Old 05-19-2009, 01:11 PM   #11
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,051

Rep: Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852
Quote:
Originally Posted by rikijpn View Post
Of course it does something, it declares a null string. If you do please "declare |grep var" the variable will still be there. This is very different from "deleting" the variable.
thanks, my guess is that instead of var taking up 4 bytes it will now take up 1 byte of ram.

can you confirm ?
 
  


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
variable stored with times on seperate lines i need to add them up shell scripting xskycamefalling Programming 4 05-16-2009 03:11 AM
Scripting: accessing a variable stored in a variable? tomolesonjr Linux - Newbie 5 05-05-2006 09:47 PM
Where can I get info on common Linux directories and what's normally stored there? hunterhunter Linux - Newbie 6 04-06-2006 04:40 PM
where are cookies (in Linux) stored. edreddy Linux - General 4 08-20-2003 06:59 PM
where are cookies in Linux are stored. edreddy Linux - Software 5 08-20-2003 12:47 AM


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