The Haiku/BeOS Tip Server
Tips and tricks for Haiku/BeOS users

Get word and line counts

Contributed by: Scot Hacker
This tip is valid for: Both BeOS and Haiku

If you prefer to write in a plain text editor such as StyleEdit, Pe, or Eddie, but need the word count feature usually only found in commercial word processors, check out the command-line word counter packaged in BeOS — a version of the Unix “wc” program.

Just open a Terminal window and CD to the location of the file you’re working on. Type wc -w filename.txt and the shell will spit back the current word count.

Keep the Terminal window open in the background and all you have to do to repeat the command is hit the Up arrow and hit return. I’ve found this is actually faster and easier than using the word count feature in other word processors.

You can also use wc to count the number of lines in a file by using the -l flag, as in wc -l filename.txt. This can be very useful in combination with other shell commands. For example, see the tip Parsing web logs with grep.

Posted in Terminal

(comments are closed).