| Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free! |
convert column to associative array
|
Original Message
|
Name: ragu
Date: April 29, 2005 at 14:08:11 Pacific
Subject: convert column to associative arrayOS: solaris 8CPU/Ram: intel |
Comment: hi Can any of the awk gurus around show me how to read 2 columns from a file and load them into an associative array. I have to do this from a ksh script. e.g if i have a file with 2 columns Stock Price --------------------- IBM 21 INTEL 12 I should be able to get the price using a map(associative array)stock_price like: price = stock_price[IBM] thnx in advance Ragu
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: nails
Date: April 29, 2005 at 16:05:16 Pacific
|
Reply: (edit) echo ""|nawk ' { while (getline < "mydata" > 0) stock_price[$1]=$2
printf("%d\n", stock_price["IBM"]) printf("%d\n", stock_price["INTEL"]) } '
Report Offensive Follow Up For Removal
|

Post Locked
This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
Go to Unix Forum Home