DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   (View Single Post)  
Old 6th May 2008
mtx's Avatar
mtx mtx is offline
Real Name: Valentin Bud
Fdisk Soldier
 
Join Date: May 2008
Location: RO/TM
Posts: 79
Default ksh arrays

i have started to use (better said learn) ksh as a scripting language about a week ago. as i was reading "Learning the Korn Shell (2nd edition)" i have reached at some point the array part.
so i have tried to make the following simple script.
Code:
# cat array.sh
#!/usr/local/bin/ksh93

K=~/bin

cd $K
KA=$(ls $PRE.*)
print ${#KA[*]}
running the script yields the following output
Code:
# ./array.sh
1
As far as i have read in the book this should print the total number of array components.
Using the -x feature of ksh i have the following output:
Code:
# ksh93 -x array.sh
+ ls addvpn.sh disk.size.sh ksh.sh s.test.sh array.sh vpn.sh
+ KA=$'addvpn.sh\ndisk.size.sh\nksh.sh\ns.test.sh\nssh.connect.sh\nvpn.sh'
+ print 1
Trying to print an element from the array let's say the first
Code:
...
print ${KA[1]}
doesn't work either. The out put is blank.
Code:
# ksh93 -x array.sh
+ ls addvpn.sh disk.size.sh ksh.sh s.test.sh ssh.connect.sh vpn.sh
+ KA=$'addvpn.sh\ndisk.size.sh\nksh.sh\ns.test.sh\nssh.connect.sh\nvpn.sh'
+ print ''
what am i missing here? thanks

all the best,
v
__________________
Stop! think! ... the problem is somewhere between the monitor and chair...
"First they ignore you, then they laugh at you, then they fight you, then you win." Gandhi
links: spreadbsd syk
Reply With Quote
 

Tags
ksh


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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Basic Perl arrays question stukov Programming 12 18th November 2008 08:44 PM
How to vectorize a function for numpy arrays in Python kasse Programming 0 26th August 2008 12:12 PM
C 2D arrays jgroch Programming 16 2nd August 2008 01:54 AM


All times are GMT. The time now is 12:21 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick