Correct me if I'm wrong, but is this for a school project?
If so take a look at the man page for bash
man bash I do know bash has a word count command also do some google searching on bash scripting
www.google.com/linux there is a ton of howto's and examples to get an idea.