Set unix shell command

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

 XMLOUTFILE=${XMLOUTDIR}/${TEST_ID}
 set -A FILES "${XMLOUTFILE}" 
+3
source share
2 answers

set -A is the Korn Shell (ksh) specification (not available in Bash or POSIX SH), and it initializes an array with the specified values.

Here is 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]}set to $XMLOUTFILE.

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

+2
source

It sets the value of the array in the shell. This array is called FILES.

-Awill specifically delete the record XMLOUTFILEand replace it.

+1
source

Source: https://habr.com/ru/post/1768357/


All Articles