Just to tickle you guys, here is an elegant expression of PR's approach - sort ids.txt | uniq -c ... the really pragmatic solution ;-P