Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 13th, 2006, 11:01 AM   #1
hush
Programmer
 
hush's Avatar
 
Join Date: Feb 2006
Location: 127.0.0.1
Posts: 35
Rep Power: 0 hush is on a distinguished road
ksh array

I am currently creating a ksh script with an array.

I was wondering if it was some how possible to call an element of an array with a variable:

e.g something like this, but not this as it does not work:

echo ${array_varible[$x]}
rather then:

echo ${array_varible[1]}
any feed back would be great

hush
hush is offline   Reply With Quote
Old Jun 13th, 2006, 1:37 PM   #2
jim mcnamara
Hobbyist Programmer
 
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4 jim mcnamara is on a distinguished road
try:
let i=0
while (( i < ${#Arr[*]} )) 
do
   echo "${Arr[i]}"
   let i=i+1
done
jim mcnamara is offline   Reply With Quote
Old Jun 14th, 2006, 10:15 AM   #3
hush
Programmer
 
hush's Avatar
 
Join Date: Feb 2006
Location: 127.0.0.1
Posts: 35
Rep Power: 0 hush is on a distinguished road
word up.

that works like a dream. nice one.

i was trying to use it in a while loop as well.
hush is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:29 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC