ksh arrays | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

ksh arrays

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-30-2013
Subbeh Subbeh is offline
Registered User
 
Join Date: May 2011
Last Activity: 24 April 2014, 9:37 AM EDT
Posts: 315
Thanks: 32
Thanked 82 Times in 81 Posts
ksh arrays

Hi,

I have a ksh script in which I need to fill an array with a list of filenames.
It currently works like this:

Code:
set -A array \
  val1 \
  val2 \
  val3

However, I was wondering why it's not possible to do something like this to make it easier to parse values to the array:

Code:
set -A array <<EOF
  val1
  val2
  val3
EOF

Sponsored Links
    #2  
Old 01-30-2013
Scrutinizer's Avatar
Scrutinizer Scrutinizer is online now Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 24 April 2014, 7:24 PM EDT
Location: Amsterdam
Posts: 8,901
Thanks: 230
Thanked 2,147 Times in 1,928 Posts
Because it would be syntactically incorrect. You could however do this:

Code:
set -A array $(
cat << EOF
  val1
  val2
  val3
EOF
)

The Following User Says Thank You to Scrutinizer For This Useful Post:
Subbeh (01-30-2013)
Sponsored Links
    #3  
Old 01-30-2013
Subbeh Subbeh is offline
Registered User
 
Join Date: May 2011
Last Activity: 24 April 2014, 9:37 AM EDT
Posts: 315
Thanks: 32
Thanked 82 Times in 81 Posts
Thanks, that makes sense
    #4  
Old 01-30-2013
Scrutinizer's Avatar
Scrutinizer Scrutinizer is online now Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 24 April 2014, 7:24 PM EDT
Location: Amsterdam
Posts: 8,901
Thanks: 230
Thanked 2,147 Times in 1,928 Posts
Or:

Code:
array=(
  val1
  val2
  val3
)

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Multidimentional arrays in KSH hraj1984 Shell Programming and Scripting 8 12-15-2011 08:29 PM
Arrays in nawk and ksh Pablo_beezo UNIX for Dummies Questions & Answers 2 11-06-2008 05:59 AM
Export Arrays in ksh ricardo.ludwig Shell Programming and Scripting 3 10-06-2008 03:16 PM
Automatic Arrays in ksh Jonny2Vests Shell Programming and Scripting 1 02-27-2008 10:20 AM
KSH and arrays whited05 Shell Programming and Scripting 1 06-24-2005 12:07 PM



All times are GMT -4. The time now is 07:50 PM.