Dec 3, 2003 #1 ianicr IS-IT--Management Joined Nov 4, 2003 Messages 230 Location 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 Joined Jul 27, 2000 Messages 2,146 Location 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 3, 2003 #3 Ygor Programmer Joined Feb 21, 2003 Messages 623 Location GB sort -u file | wc -l Upvote 0 Downvote
Dec 4, 2003 Thread starter #4 ianicr IS-IT--Management Joined Nov 4, 2003 Messages 230 Location 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 Joined Feb 21, 2003 Messages 623 Location GB awk '{a[$1]++} END {for(x in a) print a[x],x}' fileA Upvote 0 Downvote
Dec 4, 2003 #6 bigoldbulldog Programmer Joined Feb 26, 2002 Messages 286 Location 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