Dec 3, 2003 #1 ianicr IS-IT--Management Nov 4, 2003 230 GB I have a file with 500 different postcodes in it. I need to find out how many of each there are. Is there an easy way to do this?
I have a file with 500 different postcodes in it. I need to find out how many of each there are. Is there an easy way to do this?
Dec 3, 2003 #2 vgersh99 Programmer Jul 27, 2000 2,146 US man uniq uniq -c postCodes.txt vlad +----------------------------+ | #include<disclaimer.h> | +----------------------------+ Upvote 0 Downvote
man uniq uniq -c postCodes.txt vlad +----------------------------+ | #include<disclaimer.h> | +----------------------------+
Dec 4, 2003 Thread starter #4 ianicr IS-IT--Management Nov 4, 2003 230 GB Sorry if i was unclear. An example of the file is DE1 3FK DE1 4GK DE1 4LS DE5 FKG DE5 3FJ DE23 4GK I need to find out how many DE1, how many de5 and how many de23. Thanks Upvote 0 Downvote
Sorry if i was unclear. An example of the file is DE1 3FK DE1 4GK DE1 4LS DE5 FKG DE5 3FJ DE23 4GK I need to find out how many DE1, how many de5 and how many de23. Thanks
Dec 4, 2003 #5 Ygor Programmer Feb 21, 2003 623 GB awk '{a[$1]++} END {for(x in a) print a[x],x}' fileA Upvote 0 Downvote
Dec 4, 2003 #6 bigoldbulldog Programmer Feb 26, 2002 286 US awk '{print $1}' postCodes.txt | sort | uniq -c Don't forget to sort before using uniq - if already in order, then you don't have to. Cheers, ND bigoldbulldog@hotmail.com Upvote 0 Downvote
awk '{print $1}' postCodes.txt | sort | uniq -c Don't forget to sort before using uniq - if already in order, then you don't have to. Cheers, ND bigoldbulldog@hotmail.com