什么是命令的输出输入命令&QUOT后的差额; ENV","出口创汇和QUOT;,"设置"下的bash shell在Solaris中?
OS:的Solaris
OS: Solaris
壳牌:Bash shell中
Shell: Bash Shell
方案:分别输入命令:ENV,出口和set(不带任何参数),并且会有变量和值的列表返回
Scenario: Input the commands separately: "env", "export" and "set" (without any arguments) and there will be a list of variables and values returned.
我的问题:输入三个命令后有什么返回值之间的差异
My question: What's the difference among the returned values after inputting the three commands?
的 ENV
和导出
命令产生相同的信息,但不以相同的格式。和庆典
的导出
生产从 KSH 输出端的输出非常截然不同code>或(伯恩)外壳的版本。需要注意的是设置
和导出
是shell内置的命令,但 ENV
是有其他用途比刚上市时的环境内容的一个外部命令(虽然这是它的用途之一)。
The env
and export
commands yield the same information, but not in the same format. And bash
's export
produces a very radically different output from the output of ksh
or (Bourne) shell's version. Note that set
and export
are shell built-in commands, but env
is an external command that has other uses than just listing the content of the environment (though that is one of its uses).
的设置
命令列出您所创建的变量。这包括环境变量,常规(非环境)变量的和的函数定义(我们将忽略这里)。
The set
command lists the variables you've created. This includes environment variables, regular (non-environment) variables, and function definitions (which we'll ignore here).
考虑:
x1=abc
x2=def; export x2
export x3=ghi
有两个输出变量( X2
和 X3
),和一个常规(非导出)变量。在集
命令会列出所有三个; 导出
和 ENV
将只列出那些出口
There are two exported variables (x2
and x3
), and one regular (non-exported) variable. The set
command will list all three; export
and env
will only list the exported ones.
ENV
命令由POSIX标准规定。这是一个简单的变量名和值后跟一个换行符:
The output of the env
command is mandated by the POSIX standard. This is simply the variable name and value followed by a newline:
name=value
经典,Bourne shell的只是列出的变量对于设置
和出口以同样的方式
。
Korn外壳包围值引号,如果值包含空格或需要保护的其他字符,否则使用的name = value
符号。
Korn shell encloses values in quotes if the value contains spaces or other characters that need protection, but otherwise uses the name=value
notation.
在庆典
的设置
命令用引号保护的价值产生分配。然而,输出导出
是宣布-x = VAR值
帖保护。总的想法是presumably,你可以使用出口>文件
然后按源文件
来重新设置环境变量的是环境在你做的时间值出口
。
The set
command in bash
generates assignments with the value protected in quotes. However, the output for export
is a declare -x var=value
with quote protection. The general idea is presumably that you can use export > file
followed by source file
to reset the environment variables to the values that were in the environment at the time you did the export
.
- 并非所有shell变量是环境变量。
- 的
设置
命令列出所有shell变量,可能列出的功能了。 - 的
导出
命令列出的环境变量。 - 的
设置
和导出
命令内置在外壳。 - 不带参数的
ENV
命令可以列出它从执行它的进程继承了环境。
- Not all shell variables are environment variables.
- The
set
command lists all shell variables and may list functions too. - The
export
command lists environment variables. - The
set
andexport
commands are built into the shell. - The
env
command with no arguments lists the environment it inherited from the process that executed it.