Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What does Linux export mean?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

The editor will share with you what Linux export means. I hope you will gain a lot after reading this article. Let's discuss it together.

What does the Linux export command mean?

Linux export command

Function description: sets or displays environment variables.

Syntax: export [- fnp] [variable name] = [variable set value]

Additional note: when executing a program in shell, shell provides a set of environment variables. Export can add, modify or delete environment variables for use by subsequent programs. The validity of export is limited to this login operation.

Parameters:

-f represents the function name in [variable name].

-n deletes the specified variable. The variable is not actually deleted, but it is not output to the execution environment of subsequent instructions.

-p lists all the environment variables assigned to the program by shell.

When a variable is created, it is not automatically known to the shell process created after it. The command export can pass the value of the variable to the following shell. When a shell script is called and executed, it does not automatically gain access to the variables defined in the original script (caller) unless those variables have been explicitly set to available. The export command can be used to pass the values of one or more variables to any subsequent script.

After logging in to the system, the system starts a user shell. In this shell, you can use shell commands or declare variables, or you can create and run shell scripts. When you run the shell script, the system creates a child shell. At this point, there will be two shell in the system, one is the shell started by the system when logging in, and the other is the shell created by the system to run the script. When a script finishes running, its script shell terminates and you can return to the shell before the script was executed. In this sense, a user can have many shell, and each shell is derived from some shell (called the parent shell).

Variables defined in a child shell are valid only within that child shell. If a variable is defined in a shell script, when the script runs, the defined variable is only a local variable within the script, and other shell cannot reference it. To make the value of a variable can be changed in other shell, you can use the export command to output the defined variable.

The export command will cause the system to define a copy of this variable when each new shell is created. This process is called variable output.

The variables created by # echo $PKG_PATH at any time are only local to the current shell, so they cannot be used by other commands or shell programs that shell runs. Export is to pass the environment variable you set to the child SHELL of the current SHELL to make it valid in the child SHELL.

After reading this article, I believe you have a certain understanding of what Linux export means. You want to know more about it. Welcome to follow the industry information channel. Thank you for your reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report