![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Output in my shell isn't showing properly. | satyakide | Shell Programming and Scripting | 7 | 04-01-2008 07:05 AM |
| Help with showing the difference in two lines of input | Kweekwom | Shell Programming and Scripting | 12 | 02-14-2008 04:16 PM |
| displaying/ counting lines | aga | Shell Programming and Scripting | 2 | 08-08-2007 12:35 AM |
| word count showing wrong number of lines | tselvanin | UNIX for Dummies Questions & Answers | 3 | 01-06-2004 08:33 PM |
| Counting lines and files | jorge.ferreira | UNIX for Dummies Questions & Answers | 6 | 12-11-2003 08:24 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#8
|
||||
|
||||
|
Untested awk..
awk '{a[$1 FS $2]++}END{for(x in a)print x,a[x]}' infile > outfile |
| Forum Sponsor | ||
|
|
|
#9
|
||||
|
||||
|
Ha ha ...every time I see a thread like this I just wait for Ygor to respond..He's definitely one with Awk!
|
|
#10
|
|||
|
|||
|
YGOR your close to the result that i wanted
this is the output of your awk YRLNCA11-SL1 DMT8a4 13 it should have been YRLNCA11-SL1 DMT8a4 5 2 YRLNCA11-SL1 DMT8a4 6 11 the first 2 fields are still the same but the 2nd to the last is different - 5 and 6 5 appeared 2x and 6 appeared 11x almost there ... but I could still use that awk though.. THANKS |
|
#11
|
||||
|
||||
|
You could probably change Ygor's awk to
awk '{a[$1 FS $2 FS $3]++}END{for(x in a)print x,a[x]}' infile > outfile to use the first three fields as the index Cheers ZB |
|
#12
|
|||
|
|||
|
awk not clear
Please can somebody explain the awk solution of ygor and zazzybob, i tried to play with it on my machine to make some sence of it but it is not clear yet...
i am an awk lover but still biginner. |
|
#13
|
||||
|
||||
|
The awk program uses an associative array "a" to hold the count for each key. The key is the first 2 or 3 fields. At the end of the input file, loop thru the array and print each key with its count.
It's not mandatory to use awk, you could use shell utils, e.g.... $ sort infile | cut -d' ' -f-3 | uniq -c | while read A B C D; do echo $B $C $D $A; done ALBQNMMA-SL1 DMT8a4 12 1 ALBQNMMA-SL1 DMT8a4 3 4 FUTNCA01-SL1 DMT8a4 5 6 FUTNCA01-SL1 DMT8a4 6 3 |
|
#14
|
|||
|
|||
|
THANK YOU TO EVERYBODY THAT HELPED -- LEARNED A LOT!!!
|
|||
| Google The UNIX and Linux Forums |