Linux unix shell 设置命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3878543/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 23:36:51  来源:igfitidea点击:

unix shell set command

linuxshellunix

提问by Arav

Want to know what set -A option does in the below command?

想知道以下命令中 set -A 选项的作用吗?

 XMLOUTFILE=${XMLOUTDIR}/${TEST_ID}
 set -A FILES "${XMLOUTFILE}" 

回答by Starkey

It sets an array value in the shell. This array is named FILES.

它在 shell 中设置一个数组值。这个数组被命名为FILES

The -Awill specifically delete the XMLOUTFILEentry, and replace it.

-A会专门删除XMLOUTFILE条目,替换它。

回答by dandu

set -Ais Korn Shell (ksh) specific (not available in Bash or POSIX SH) and it initializes an array with the specified value(s).

set -A是 Korn Shell (ksh) 特定的(在 Bash 或 POSIX SH 中不可用),它用指定的值初始化一个数组。

Here's an example:

下面是一个例子:

$ set -A COLORS "red" "green" "blue"
$ print ${COLORS[0]}
red
$ print ${COLORS[1]}
green
$ print ${COLORS[2]}
blue

In your example, ${FILES[0]}is set to $XMLOUTFILE.

在您的示例中,${FILES[0]}设置为$XMLOUTFILE.

Instead of using set -Ayou can also use for example ARRAY[0]="value"which is more portable.

除了使用,set -A您还可以使用例如ARRAY[0]="value"更便携的。

回答by Ashiq Imran

set -A FILES "${XMLOUTFILE}" will replace the XMLOUTFILE entries from FILES array.

set -A FILES "${XMLOUTFILE}" 将替换 FILES 数组中的 XMLOUTFILE 条目。