Linux怎么用命令清空Bash环境变量
  • 作者:zhijie
  • 时间:2023-02-09

  例子:使用 http_proxy

  1.$ wget www.cyberciti.biz

  2.--2015-08-0323:20:23-- http://www.cyberciti.biz/

  3.Connecting to 10.12.249.194:3128... connected.

  4.Proxy request sent, awaiting response...200 OK

  5.Length: unspecified [text/html]

  6.Saving to:‘index.html’

  7.index.html [《=》]36.17K87.0KB/s in0.4s

  8.2015-08-0323:20:24(87.0 KB/s)-‘index.html’ saved [37041]

  例子:忽视 http_proxy

  1.$ env -i /usr/local/bin/wget www.cyberciti.biz

  2.--2015-08-0323:25:17-- http://www.cyberciti.biz/

  3.Resolving www.cyberciti.biz.。.74.86.144.194

  4.Connecting to www.cyberciti.biz|74.86.144.194|:80... connected.

  5.HTTP request sent, awaiting response...200 OK

  6.Length: unspecified [text/html]

  7.Saving to:‘index.html.1’

  8.index.html.1[《=》]36.17K115KB/s in0.3s

  9.2015-08-0323:25:18(115 KB/s)-‘index.html.1’ saved [37041]

  -i 选项使 env 命令完全忽视它继承的环境。但是,它并不会阻止你的命令(例如 wget 或 curl)设置新的变量。同时,也要注意运行 bash/ksh shell 的副作用:

  1.env -i env | wc -l ## 空的 ##

  2.# 现在运行 bash ##

  3.env -i bash

  4.## bash 设置了新的环境变量 ##

  5.env | wc -l

  例子:设置一个环境变量

  语法如下:

  1.env var=value /path/to/command arg1 arg2 ...

  2.## 或 ##

  3.var=value /path/to/command arg1 arg2 ...

  例如设置 http_proxy:

  1.env http_proxy=“http://USER:PASSWORD@server1.cyberciti.biz:3128/”/usr/local/bin/wget www.cyberciti.biz

  以上就是Linux怎么用命令清空Bash环境变量的全部内容了,可以看到env的命令还是很强大的,有兴趣的朋友可以去体验一下。

 2/2   首页 上一页 1 2
相关推荐
用户评论区