uTools-Manuals/docs/linux/export.html
2019-04-21 11:50:48 +08:00

38 lines
2.8 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<h1 id="export">export</h1>
<p>设置或显示系统环境变量</p>
<h2 id="补充说明">补充说明</h2>
<p><strong>export命令</strong> 用于将shell变量输出为环境变量或者将shell函数输出为环境变量。</p>
<p>一个变量创建时它不会自动地为在它之后创建的shell进程所知。而命令export可以向后面的shell传递变量的值。当一个shell脚本调用并执 行时它不会自动得到原为脚本调用者里定义的变量的访问权除非这些变量已经被显式地设置为可用。export命令可以用于传递一个或多个变量的值到任何后继脚本。</p>
<h3 id="语法">语法</h3>
<pre><code class="language-bash">export(选项)(参数)</code></pre>
<h3 id="选项">选项</h3>
<pre><code class="language-bash">-f代表[变量名称]中为函数名称;
-n删除指定的变量。变量实际上并未删除只是不会输出到后续指令的执行环境中
-p列出所有的shell赋予程序的环境变量。</code></pre>
<h3 id="参数">参数</h3>
<p>变量:指定要输出或者删除的环境变量。</p>
<h3 id="实例">实例</h3>
<p>一般来说,配置交叉编译工具链的时候需要指定编译工具的路径,此时就需要设置环境变量。查看已经存在的环境变量:</p>
<pre><code class="language-bash">[root@localhost ~]# export
declare -x G_BROKEN_FILENAMES=&quot;1&quot;
declare -x HISTSIZE=&quot;1000&quot;
declare -x HOME=&quot;/root&quot;
declare -x hostname=&quot;localhost&quot;
declare -x INPUTRC=&quot;/etc/inputrc&quot;
declare -x LANG=&quot;zh_CN.UTF-8&quot;
declare -x LESSOPEN=&quot;|/usr/bin/lesspipe.sh %s&quot;
declare -x logname=&quot;root&quot;
declare -x LS_COLORS=&quot;no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:&quot;
declare -x mail=&quot;/var/spool/mail/root&quot;
declare -x OLDPWD
declare -x PATH=&quot;/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin&quot;
declare -x pwd=&quot;/root&quot;
declare -x SHELL=&quot;/bin/bash&quot;
declare -x SHLVL=&quot;1&quot;
declare -x SSH_CLIENT=&quot;192.168.2.111 2705 22&quot;
declare -x SSH_CONNECTION=&quot;192.168.2.111 2705 192.168.2.2 22&quot;
declare -x SSH_TTY=&quot;/dev/pts/0&quot;
declare -x TERM=&quot;linux&quot;
declare -x USER=&quot;root&quot;</code></pre>
<!-- Linux命令行搜索引擎https://jaywcjlove.github.io/linux-command/ -->