![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| calculate 13 months ago | andrea_mussap | Shell Programming and Scripting | 4 | 11-21-2007 05:14 PM |
| calculate 13 months ago | andrea_mussap | Shell Programming and Scripting | 3 | 11-16-2007 12:18 PM |
| Count No of Records in File without counting Header and Trailer Records | guiguy | Shell Programming and Scripting | 2 | 06-07-2007 09:15 AM |
| How To Calculate | krishna_sicsr | Shell Programming and Scripting | 1 | 03-28-2007 07:24 AM |
| How to calculate with awk | whatisthis | Shell Programming and Scripting | 4 | 11-09-2005 09:39 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#8
|
||||
|
||||
|
You could use awk, but then you have a requirement to find the frequency based on the first 2 characters of the 4th field.
I am not sure, how you can extract characters using awk. Probably someone could post a solution for that. Vino |
| Forum Sponsor | ||
|
|
|
#9
|
||||
|
||||
|
Code:
awk -F"\t" '{a[substr($4,1,2)]++}END{for (i in a) print i,a[i]}'
|
|
#10
|
|||
|
|||
|
Quote:
When you this a[$3]+=$2 this means that you put the 3rd field in a table and you assign his value to be equal with the sum of its second field????? And why we don't get many times the same 3rd field when printing (I don't want to be printed many times, I just want to understand how it is working). Cheers |
|
#11
|
||||
|
||||
|
Quote:
with the following data 386 8192 A423 CC0177 40 586 65536 A424 CC0182 670 486 16384 A423 CC0183 100 486 16384 A425 CC0184 80 65000 4096 B407 EE1027 80 AWK processes data line by line line #1: a["A423"]=a["A423"]+8192=8129 line #2: a["A424"]=a["A424"]+65536=65536 line #3: a["A423"]=a["A423"]+16384=8129+16384 ... ... ... Sorry for my pool English. That's all what I can explain to you. |
||||
| Google The UNIX and Linux Forums |