LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-29-2015, 01:29 PM   #1
legendmac
LQ Newbie
 
Registered: Apr 2015
Location: AZ
Posts: 14

Rep: Reputation: Disabled
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.
 
Old 05-29-2015, 02:45 PM   #2
legendmac
LQ Newbie
 
Registered: Apr 2015
Location: AZ
Posts: 14

Original Poster
Rep: Reputation: Disabled
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.
 
  


Reply

Tags
array, ksh, linux, shell scripting


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] how to declare an array from command substitution in bash mia_tech Linux - General 1 03-08-2014 02:18 PM
BASH-Adding array element: Naming issue using array[${#array[*]}]=5 calvarado777 Programming 8 07-26-2013 10:48 PM
[SOLVED] unable to declare array in Solaris ankitpandey Programming 10 12-27-2012 05:19 PM
[SOLVED] Can't declare an array of pointers to member functions KenJackson Programming 3 09-03-2010 04:08 PM
Refer to object without name (with array reference)...is this valid? jmite Programming 13 11-24-2009 09:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration