How to Get a Word Count in Unix using Bash/Terminal
This short guide will teach you how to get a word count in Unix using Bash/Terminal. It's also possible get a character count in Unix—check out our guide to see how it's done.
This short guide will teach you how to get a word count in Unix using Bash/Terminal. It's also possible get a character count in Unix—check out our guide to see how it's done.
In your shell, or Terminal on a Mac, type:
wc -l filename
.. replacing filename with the actual name of the file. This should print the number of lines like so:
$ wc -l test.php
18 test.php
If you want to find out how many characters are in a file here's how! You can also get a word count in Unix which is useful if you need to keep track of more than just individual characters.