There were more commands to register environmental variables than I thought. I think you can use env, set, export, and declare Why are there so many commands?
And is there a difference between these instructions?
linux environment-variables
These are the Bash (or sh) built-in commands that Linux uses the most.
Each command has a slightly different usage.
env : Commands to show, set, or delete environment variables. http://ss64.com/bash/env.html
$ env
Outputs environment variables defined in the current session to the screen.
$ env NAME=VALUE
Specify a value called VALUE in the environment variable called NAME.
$ env -u NAME
Deletes the NAME environment variable.
set : The command to manage the shell variable in Bash. http://ss64.com/bash/set.html
set NAME=VALUE
# In Bash, you can omit:
NAME=VALUE
The shell variable is the variable used in the shell script language called Bash, and the environment variable is the variable used by the operating system (for example, PATH).
To turn it off, use the unset command.
export: This command changes the shell variable to the environment variable.
NAME=VALUE
export NAME
The above uses set and export to obtain the same results as the following commands:
env NAME=VALUE
declare: This is a command that specifies the type of shell variable. https://wiki.kldp.org/HOWTO/html/Adv-Bash-Scr-HOWTO/declareref.html
Use to declare the nature of a shell variable as read-only, integer, array, function, etc.
Note
© 2024 OneMinuteCode. All rights reserved.