![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Assigning the values to an Array | kkraja | Shell Programming and Scripting | 1 | 08-11-2008 07:28 AM |
| perl: Assigning array values.. | looza | Shell Programming and Scripting | 4 | 07-15-2008 09:08 AM |
| How to use array values after the loop. | Devesh5683 | Shell Programming and Scripting | 1 | 05-13-2008 08:38 PM |
| assigning values to a variable | trichyselva | UNIX for Dummies Questions & Answers | 3 | 12-14-2007 01:55 AM |
| Assigning values to an array | yongho | UNIX for Dummies Questions & Answers | 4 | 07-13-2005 09:49 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Assigning values to an array via for/while loop
I need to do something like this: Code:
for i in 1 2 3 4 5; do
arr[$i]=$(awk 'NR="$i" { print $2 }' file_with_5_records)
done
That is, parse a file and assign values to an array in an ascending order relative to the number of record in the file that is being processed on each loop. Is my syntax wrong? Is there a trick? I can't seem to get the values assigned properly, does the shell forget them when it exits the loop? Is this even possible? |
| Bookmarks |
| Tags |
| shell script, shell scripting, unix scripting, unix scripting basics |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|