Multidimentional arrays in KSH

Hi,

I am using KSH shell and need to define a multi dimensional array in which i need to store and retrive data. Please provide your valuable in puts.
Eg: asbjkasd 1234
asdhnas 1254
i need to store the above values and use them as input to another command.
Note each line is a pair.
Thanks for your help in advance.

Why do you need multi dimensional array for that?... besides, I am not sure if KSH has it... Bash v4 got multi-dim array support...
What is your goal?... Give us some more information...

--ahamed

Hi,

Here is the scenario, i run a command and need to parse it to the next command to perform a action, but the trick part is the first command can provide 1 or more lines of output but with the 2 words separated by space in each line. The 2 words are to be passed together as and argument to the next command.
Hence my approach was to store them in an array and pass them one by one to the next command.
Thanks in advance.

Could you post an output example and what values do you want in variables. With that, you can send to another script.

A single dim array could store the arg list

eg:

#!/bin/ksh
while read arg_list
do
    line[${#line[@]}]="$arg_list"
done <<EOF
asbjkasd 1234
asdhnas 1254
-l acid 1404
-q steel 92
EOF
 
i=0
while [ $i -lt ${#line[@]} ]
do
   echo "line[$i]: ${line}"
   let i=i+1
done

output:

line[0]: asbjkasd 1234
line[1]: asdhnas 1254
line[2]: -l acid 1404
line[3]: -q steel 92

Hi,

The command I run is "

set -A ctm_Condarray `ctmpsm -LISTFULLDETAILS $1 |grep 'Out Condition' |awk -F '[|:]' '{print $2,$4 }'` "

Output is

 C_AI_BARIMP001_SSIS_DELFILE_OK   1215
 C_AI_BARIMP001_ARCHIVE_SSIS_OK   1215
 C_AI_BARIMP001_EGLCTL209_HC_RUN   1215

Now each of the line is sort of pair and need to be passed to another command in the script as argument like

ctmcontb -ADD C_AI_BARIMP001_EGLCTL209_HC_RUN   1215

Thanks

How about

ctmpsm -LISTFULLDETAILS $1 | awk -F '[|:]' '/Out Condition/ {print $2,$4 }' | while read arg1 arg2 rest
do
    ctmcontb -ADD $arg1 $arg2
done
1 Like

Thanks Works great :slight_smile:

Recent versions of ksh93 have multidimensional array support.