Unix OSs (and derivatives like Linux, MacOS etc) have full array of command-line tools for that: wc, uniq, etc. Some of these tools are ported also for Windows, like in Cygwin project.
Are you doing a homework project, or looking for ready-made tools?