Show word count with Pandoc and a lua script
To show word and character count (skipping metadata and Markdown syntax) of a file, first download the lua script wordcount.lua
(there is a copy of the script hosted on this website) by running:
$ wget https://yctct.com/wordcount.lua
Then, to show word and character count of a file run:
$ pandoc file --lua-filter=path/to/file/wordcount.lua
If the file containing the script wordcount.lua
is located in the same directory as the file you wish to count words of, you can run:
$ pandoc file --lua-filter=wordcount.lua
The terminal should print something like:
449 words in body
2114 characters in body
2551 characters in body (including spaces)
If you need to download Pandoc, on Trisquel GNU/Linux run:
$ sudo apt install pandoc
What is the difference between using the programme wc and the script wordcount.lua
to count words?
wc
will count all characters, including those that are commented out, Markdown syntax and metadata whereas wordcount.lua
will skip those.
command-line interface (cli) personal computing pandoc trisquel GNU linux text processing office applications wiki shell literacy