Setting environment Variables
The article directories
- Setting environment Variables
-
- 1. Basic grammar
- 2. Quick start
- 3. Multi-line comments for shell scripts
1. Basic grammar
Export Variable name = variable value
(Function description: Output shell variables as environment variables/global variables)Source configuration file
(Function description: The modified configuration takes effect immediately.)Echo $variable name
(Function description: Query the value of environment variables)
2. Quick start
- The centos install tomcat, access to I used to write blog posts: xdr630.blog.csdn.net/article/det…
- Download and unzip:
- in
/etc/profile
File definitionTOMCAT_HOME
The environment variable - Viewing environment Variables
TOMCAT_HOME
The value of the - Used in another shell program
TOMCAT_HOME
Note: in the outputTOMCAT_HOME
Environment variables need to be in effect before:source /etc/profile
- Output TOMCAT_HOME using the environment variable
# Output TOMCAT_HOME using the environment variable
echo "tomcat_home=$TOMCAT_HOME"
Copy the code
3. Multi-line comments for shell scripts
- The following is commented out
: < <! Content!Copy the code
: < <! A=100Output variables need $
echo "A=$A"
# Case 2: Undo variable A
unset A
echo "A=$A"
!
Copy the code