The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




Thread: using array
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 02-06-2007
Glenn Arndt's Avatar
Glenn Arndt Glenn Arndt is offline Forum Advisor  
Anomalous Lurker
  
 

Join Date: Feb 2006
Location: Indianapolis, IN
Posts: 255
What is the field delimiter? The following assumes a comma:
Code:
integer i=0
awk 'BEGIN {FS=OFS=","} {print $3}' file.txt | while read item; do
  myarray[$i]=$item
  i=$i+1
done

If the fields are delimited by spaces, just eliminate the BEGIN block:
Code:
integer i=0
awk '{print $3}' file.txt | while read item; do
  myarray[$i]=$item
  i=$i+1
done