LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 01-19-2004, 06:59 PM   #1
apoc013
Member
 
Registered: Jan 2004
Location: New York
Distribution: Red Hat 9
Posts: 31

Rep: Reputation: 15
Question Help with the currently set environment variables!!


How do I get all the currently set environment variables to display and print out to a text file.

I know that I can use the printenv command, but I can't get it to save or print to a file.

Thanks in advance!
 
Old 01-19-2004, 07:02 PM   #2
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
i think /etc/profile is what your looking for (note this is the universal localation for it, each usr should ahve there own profile file were tehy decalre variables, look in the /etc/passwd file to see were teh location for the file should be (if its not there then /etc/profile is the file to use) optionaly you can declare variables in the startupscripts i think
 
Old 01-19-2004, 10:22 PM   #3
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
you can use:

printenv > filename

That will send the output of printenv to the file filename
 
Old 01-19-2004, 11:18 PM   #4
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Is the difference between 'printenv' and 'set' that printenv lists all (and only) general variables and the set builtin lists those plus bash-specific variables?
set > set.out
produces a much larger file with more variables. The printenv man page has been info-ized (says much of nothing except directing me to damn info pages) so I don't know, but that's my guess based on the differences of the two files.
 
Old 01-19-2004, 11:58 PM   #5
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
Just took a quick look at the man pages. Looks like 'printenv' will display
only exported variables, while 'set' will display in addition those that
haven't been exported. (set is also a BASH builtin, while printenv isn't).

I'm open to criticism on the above.

*edit*

No, I tried it. There's more to it than that. Some BASH-specific global
variables are missing from printenv's output, as you pointed out.

Last edited by Berhanie; 01-20-2004 at 12:09 AM.
 
Old 01-20-2004, 01:30 AM   #6
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Hm. I just loaded csh (which has a 'printenv' builtin) and doing 'printenv > file' produces yet another output - almost identical to the external printenv as run by bash, but with a handful of others. But running the external printenv *with* csh produces an identical file to the csh builtin.

Dunno where to go with any of this, but I was just curious. I've always used the 'set' builtin and had never tried 'printenv'.
 
Old 01-21-2004, 01:28 AM   #7
apoc013
Member
 
Registered: Jan 2004
Location: New York
Distribution: Red Hat 9
Posts: 31

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by Berhanie
you can use:

printenv > filename

That will send the output of printenv to the file filename





Thanks it worked great!
 
  


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
SLES: Why don't my environment variables get set? eantoranz Linux - Software 4 11-01-2005 11:49 AM
how do i set environment variables? guitarfella Slackware 2 12-04-2004 11:05 PM
Why can't my scripts set environment variables? Matthew3 Linux - Software 5 08-28-2004 05:26 PM
How to set environment variables anjaan Linux - General 3 06-10-2004 02:04 PM
set environment variables using GUI? bax Linux - Software 2 04-10-2004 02:42 PM

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

All times are GMT -5. The time now is 01:42 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
Open Source Consulting | Domain Registration