Setting environment Variables

The article directories

1. Basic grammar

  1. Export Variable name = variable value(Function description: Output shell variables as environment variables/global variables)
  2. Source configuration file(Function description: The modified configuration takes effect immediately.)
  3. 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:

  1. in/etc/profileFile definitionTOMCAT_HOMEThe environment variable
  2. Viewing environment VariablesTOMCAT_HOMEThe value of the
  3. Used in another shell programTOMCAT_HOME

    Note: in the outputTOMCAT_HOMEEnvironment 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