Differences between set, ENV, and export

Source: Internet
Author: User

Set: display the current shell variables, including the current user Variables

Env: Display User Variables

Export: displays the shell variables currently exported as user variables.

For example:

[Email protected]: ~ # AAA = BBB: Set a variable. The variable set at this time is a shell variable.
[Email protected]: ~ # Echo $ AAA display the variable you just set
Bbb
[Email protected]: ~ # Set | grep AAA display and search for the current shell variable, find the AAA variable you just set
AAA = bbb
[Email protected]: ~ # Env | grep AAA: displays and searches for the variables of the currently logged-on user. AAA is a shell variable and cannot be searched.
[Email protected]: ~ # Export AAA export the shell variable AAA to the user variable
[Email protected]: ~ # Env | grep AAA: Search for user variables to search for AAA.
AAA = bbb
[Email protected]: ~ #


Each shell has its own unique variables, which are different from user variables. The current user variables have nothing to do with what shell you use, no matter what shell you use. Such as home and shell, but Shell also has its own variables. Different shells are different, such as bash_argc and bash. These variables are only displayed in set, is unique to bash. When an export parameter is not added, it shows which variables are exported as user variables, because a shell variable can be changed to a user variable through export "Export.


Run the unset command to clear environment variables. You can use unset to clear all variables set by set env export.

In addition, the shell (Bash here) initialization process is as follows:

1. Bash check whether the file/etc/profile exists

2. If yes, Bash will read the file. Otherwise, skip

3. Bash check whether the file. bash_profile in the main directory exists.

4. If the file exists, bash reads the file. Otherwise, skip

5. Bash check whether. bash_login in the main directory exists.

6. If the file exists, bash reads the file. Otherwise, skip

7. Bash check whether the file. profile in the main directory exists

8. If the file exists, Bash will read the file. Otherwise, it will be skipped.

After these steps are completed, a prompt is displayed. The KSh default prompt is $.




Reference

Http://www.opsers.org/base/set-env-and-export-the-difference-between-the-three-command.html

Http://blog.csdn.net/longxibendi/article/details/6125075

Http://www.linuxeden.com/html/sysadmin/20080424/56879.html

Differences between set, ENV, and export

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.