什么是命令的输出输入命令&QUOT后的差额; ENV","出口创汇和QUOT;,"设置"下的bash shell在Solaris中? [英] What's the difference of the command output after inputting the command "env", "export", "set" under Bash Shell in Solaris?

查看:254
本文介绍了什么是命令的输出输入命令&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 导出命令产生相同的信息,但不以相同的格式。和庆典导出生产从<​​code> KSH 或(伯恩)外壳的版本。需要注意的是设置导出是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,你可以使用出口&GT;文件然后按源文件来重新设置环境变量的是环境在你做的时间值出口

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.


  1. 并非所有shell变量是环境变量。

  2. 设置命令列出所有shell变量,可能列出的功能了。

  3. 导出命令列出的环境变量。

  4. 设置导出命令内置在外壳。

  5. 不带参数的 ENV 命令可以列出它从执行它的进程继承了环境。

  1. Not all shell variables are environment variables.
  2. The set command lists all shell variables and may list functions too.
  3. The export command lists environment variables.
  4. The set and export commands are built into the shell.
  5. The env command with no arguments lists the environment it inherited from the process that executed it.

这篇关于什么是命令的输出输入命令&QUOT后的差额; ENV&QUOT;,&QUOT;出口创汇和QUOT;,&QUOT;设置&QUOT;下的bash shell在Solaris中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆