The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 11-01-2006
Glenn Arndt's Avatar
Glenn Arndt Glenn Arndt is offline Forum Advisor  
Anomalous Lurker
  
 

Join Date: Feb 2006
Location: Indianapolis, IN
Posts: 255
I don't know if there's any way to retrieve the index/subscript directly. You'll probably have to count and increment it yourself:
Code:
set -A week_array Sunday Monday Tuesday Wednesday Thursday Friday Saturday
integer idx=0

for day in ${week_array[*]}
 do
  print $idx $day
  idx=$idx+1
done

You can also set the array variables this way:
Code:
week_array[0]=Sunday
week_array[1]=Monday
week_array[2]=Tuesday
week_array[3]=Wednesday
week_array[4]=Thursday
week_array[5]=Friday
week_array[6]=Saturday