![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 |
| Array problem | ajgwin | Shell Programming and Scripting | 0 | 05-27-2008 09:36 AM |
| problem with array=($(find ....) | jul | Shell Programming and Scripting | 1 | 02-27-2008 04:28 PM |
| problem with the blank spaces in array | kamicasse | UNIX for Dummies Questions & Answers | 4 | 12-06-2007 02:40 PM |
| Point and Array Convert Problem | zhshqzyc | High Level Programming | 0 | 02-25-2006 09:28 PM |
| char array problem | DebianJ | High Level Programming | 4 | 06-25-2005 10:41 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
array problem
Dear Experts,
please help me out once again my array concepts is not very clear i have one text file like. 1|usa|hh 2|usa|ll 3|usa|vg 4|uk|nn 5|uk|bb 6|kuwait|mm 6|kuwait|jkj 7|dubai|hh i want to store the third fied of a text file in he array and after that it should give me some reports like this third field count usa 3 uk 2 kuwait 2 dubai 1 it should store the third field in to the array and give me the count how many times any name appeared.the third field can be alphanumeric. please can any body tell me how to do this using array. Regards, Shary |
|
||||
|
try this:
even I have been looking for a awk script for that its something like group by columns and then the count. I have awk to do group by and the sum: awk -F, '{sum[$1,$2,$3]+=$4} END {for (i in sum) print i, sum[i]}' data. Thanks SUmeet |
|
||||
|
array problem
Dear Summit,
thank you so much for replying me i really appreciate you but please can you expalin me this {sum[$1,$2,$3]+=$4} what does this mean in array coz my array concept is weak and the other thing i want to store only 3rd field but in your case it seems to be stored 1,2,3 fileds right . the data might be 1000 line in my text file so please can you brief it out your command awk -F, '{sum[$1,$2,$3]+=$4} END {for (i in sum) print i, sum[i]}' data. Regards, Shary |
|
||||
|
using array
dear experts,
thank uou so much it really works. take care bye shary |
| Sponsored Links | ||
|
|