Learn how to read local environment variables and environment variables on the server by shell

USER=abbott
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.kLlEVaU801/Listeners
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/mysql/bin:/usr/local/mongodb/bin
PWD=/Users/abbott
UNIVER_MONGO_URL=mongodb://10.10.0.49:27017
LANG=zh_CN.UTF-8
XPC_FLAGS=0x0
XPC_SERVICE_NAME=0
SHLVL=1
HOME=/Users/abbott
LOGNAME=abbott
REACT_APP_SECRET_CODE=mongodb://10.10.0.49:27017
_=/usr/bin/env

this is the environment variable of my computer. How to use shell to read

Apr.01,2021

use env , printenv to see all the available environment variables under the current shell, and use export to see the environment variables that are currently being export, that is, the environment variables that can play a role in the child process.

you can only use ${ENV_VAR_NAME} to read an environment variable in a shell script

Menu