env
进程与系统
用法
env [VAR=value] [command]打印整个环境变量表,或者带上额外变量运行一条命令;那些变量只对这一次运行生效,你的 shell 里不留下任何东西。
常用选项
| 选项 | 含义 |
|---|---|
| env | With no arguments, print the whole environment. |
| VAR=value <command> | Run the command with that variable added, for this run only. |
| -i | Start from an empty environment, inheriting nothing. |
| -u <VAR> | Unset one variable for the child process. |
示例
env | sort | grep -i proxyFind the proxy variables that are breaking a download.
env NODE_ENV=production node app.jsSet a variable for one run without touching your shell.
env -i bash --noprofile --norcA shell with nothing inherited, for reproducing a cron failure.
看什么在跑、什么在吃机器。先弄清是什么,再决定杀不杀。
怎么看
- 方括号 [ ] 表示这部分可以不写。
- 省略号 … 表示可以写多个。
- 选项区分大小写——有些命令里 -r 和 -R 不是一回事。
常见问题
Q. env 是做什么的?
打印整个环境变量表,或者带上额外变量运行一条命令;那些变量只对这一次运行生效,你的 shell 里不留下任何东西。
Q. 怎么写?
env [VAR=value] [command] —— 方括号表示可以省略的部分。
Q. 值得记的选项有几个?
这里列了 4 个,完整列表在 man env。这条命令属于进程与系统。
相关命令
man 手册: man env