Sort and count using AWK

Hi,

I've a fixed width file where I need to count the number of patterns from each line between characters 1 to 15 . so can we sort them and get a count for each pattern on the file between 1 to 15 characters.

65795648617522383763831552  410828003265795648  6175223837
82255637216297152582255637  216297152565795648  6175223837                
61037863301869758061037863  301869758065795648  6175223837          
638315524108280032 63831552  4108280032         
617522383763831552  410828003265795648  6175223837
326579564863831552  4108280032 63831552  4108280032
3301869758061037863  301869758065795648  6175223837  
cut -c1-15 < myFile |sort -n | uniq -c
awk '{a[substr($0,1,15)]++}END{for(i in a) print a,i | "sort -nk2"}' file

This can be written with one less pipe and process: -

cut -c1-15 < infile |sort -n -u

OUTPUT: -

326579564863831
330186975806103
610378633018697
617522383763831
638315524108280
657956486175223
822556372162971

... and where you count ? did you check the OP request?

:rolleyes:

Nope, not been that sharp today, my bad.......