The linux export command can be used to set or display environment variables; when executing a program in the shell, you can use export to add, modify or delete environment variables for subsequent execution of the program, the syntax format is “export [-fnp][variable name]=[variable setting value]”.
Function description:
Set or display environment variables. (For example, we want to use a command, but the execution file of this command is not in the current directory, so we must specify the directory of the execution file every time we use it. Trouble, first execute export in the code, which is equivalent to telling the program to execute a certain When you need something, the files you need or what stuff is in these directories)
Syntax:export [-fnp][variable name]=[variable setting value]
Supplementary note: When executing a program in the shell, the shell will provide a set of environment variables. export can add, modify or delete environment variables for use by subsequent programs. The effect of export is limited to the login operation.
Parameters:
-f means [variable name] is the function name.
-n Delete the specified variable. The variable is not actually deleted, it is just not output to the execution environment of subsequent instructions.
-p List all the environment variables given to the program by the shell.
When a variable is created, it is not automatically known to shell processes created after it. The command export can pass the value of the variable to the subsequent shell. When a shell script is invoked and executed, it does not automatically gain access to variables defined in the script (the caller), unless those variables have been explicitly made available. The export command can be used to pass the value of one or more variables to any subsequent scripts. —- “UNIX Tutorial”
Generally speaking, when configuring the cross-compilation toolchain, you need to specify the path of the compilation tool. environment variables need to be set. For example, my mips-linux-gcc compiler is in the “/opt/au1200_rm/build_tools/bin” directory, and build_tools is my compilation tool. There are three ways to set environment variables:
1. Use the export command directly:
#export PATH=$PATH:/opt/au1200_rm/build_tools/bin
Check if it has been set, you can use the command export to check:
2. Modify the profile file:
#vi /etc/profile Add in it: export PATH="$PATH:/opt/au1200_rm/build_tools/bin"
3. Modify the .bashrc file:
# vi /root/.bashrc Add in it: export PATH="$PATH:/opt/au1200_rm/build_tools/bin"
The latter two methods generally need to log out of the system again to take effect, and finally you can pass Test the echo command:
# echo $PATH
For more knowledge about programming, please visit: Programming Video Course! !
The above is how to use the export command under linux? For more details, please pay attention to other related articles on 1024programmer.com!