Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 01-13-2006, 12:56 PM   #1
Registered: Sep 2003
Distribution: LFS6.1, FC3, RH9
Posts: 36

Rep: Reputation: 15
Difference between "set" and "env"?

When trying to output a list of all the environment variables, I notice that there is a difference between "set" and "env". An obvious difference is that "set" outputs quoted strings and "env" does not quote. But of more concern is that "env" omits some of the variables that "set" displays.

Why are some variables that are displayed with "set" not displayed with "env"?

Is there a particular method of creating an environment variable that prevents it from being passed to a new environment?

- Joe
Old 01-13-2006, 02:50 PM   #2
LQ Veteran
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392

Without options, the name and value of each shell variable are displayed in a format that can be reused as input. The output is sorted according to the current locale.

A 'limited' execution environment with specific content.

For details on the content and ways to manipulate, take a look at man bash the COMMAND EXECUTION ENVIRONMENT and ENVIRONMENT section.

Hope this helps.
Old 01-13-2006, 04:37 PM   #3
Registered: Sep 2003
Location: Canada
Distribution: Fedora 25
Posts: 340

Rep: Reputation: 36
And I always thought it was the difference between local and global...

Global environment variables are set by your login shell and new programs and shells inherit the environment of their parent shell.

Local shell variables are used only by that shell and are not passed on to other processes.

You can list your global environmental variables with the env or printenv commands. You unset them with the unsetenv (C shell) or unset (Bourne shell) commands.

To set a local shell variable use the set command with the syntax below for C shell. Without options set displays all the local variables.


env, set

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
newbie question: whats the difference between "su root", "su" and "su -&quo mojarron Slackware 9 12-07-2009 04:08 PM
problem "make"ing gtk+ "/usr/bin/env: perl -w" caid Linux - Newbie 8 07-29-2005 04:51 AM
Can you explain the difference between "Free Software (GNU)" and "Open Source"? vharishankar General 5 03-03-2005 09:40 AM
difference between "Web server local URL" and "IPv4 address"? kpachopoulos Linux - General 2 09-17-2004 01:30 PM
"User" & "System" CPU load difference JJX Linux - General 3 06-06-2004 01:42 AM > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration