Linux – unix shell setup commands

unix shell setup commands… here is a solution to the problem.

unix shell setup commands

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

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

Solution

Set -A is Korn Shell (ksh)-specific (not available in Bash or POSIX SH) and 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]} is set to $XMLOUTFILE.

In addition to using set -A, you can also use the more portable ARRAY[0]="value", etc.

Related Problems and Solutions