LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to determine if syntax array=( str1 str2 str3 ) to declare array is valid (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-determine-if-syntax-array%3D-str1-str2-str3-to-declare-array-is-valid-4175543968/)

legendmac 05-29-2015 12:29 PM

How to determine if syntax array=( str1 str2 str3 ) to declare array is valid
 
Hi, I am creating a Korn shell script and need to create an array where each element corresponds to one line of an input file. Being able to do the following would be awesome:
Code:

array=( $(cat file.txt) )
However, I'm finding that not all of my development boxes allow this. Some return this:
Code:

ksh: syntax error: `(' unexpected
I suspect this has something to do with the Korn shell version. Does anyone know how I can find out what version is required in order to be able to declare arrays, as above? Or is this an OS version issue?

I would really appreciate any tips on how I can find out the minimum requirements for this syntax to be valid.

Thanks.

legendmac 05-29-2015 01:45 PM

Did not find any specific documentation, but was able to determine from my boxes, that it only works on ksh93. On other versions of KSH, need to use the "set -A array" or "array[index]=..." methods.


All times are GMT -5. The time now is 04:51 AM.