I'm working on two-year project using the classicthesis template. My project folder, ie. the classicthesis template folder, includes several .tex files, for example all nine project chapters as their own .tex files.

I've found a tool for tracking and plotting all the words in my project, but don't understand how to set it up on my Mac.

Having studied the instructions below, taken from the aforementioned site, my core problem is that PowerShell scripts don't work on OS X, right... ?

Here is the script in case you are interested: twc.ps1. I suggest you to use it to monitor your progress on your writings by setting it as a daily job under the Windows Task Scheduler.

The usage syntax is ./twc.ps1 [-tag name] [-date date] [-output outputdir] inputdirs

For example the command ./twc.ps1 -tag first_version -date '16 Nov 2010' -output c:\report c:\thesis creates a datapoint named 'first_version' at the specified date whose value is the total number of words in TeX documents under directory c:\thesis; the CSV file and graphs are stored under c:\report.

Am I missing something here, perhaps a better idea... ?


If you just want to count how many times each word occurs in your tex files then the following one-liner will most likely work on Mac. Run it in Terminal from a directory with your tex files:

for w in $(cat *.tex); do echo $w; done | sort | uniq -c | sort -g 

It outputs words and their occurrences counts ordered by the latter in ascending order. A word is a non-zero-length sequence of characters delimited by white space.

Having this done and result saved in a file, you can plot the result using e.g. pgfplots package.

If you need to just count all words and append this number with the current date to CSV file then this will do the trick

echo "$(date +"%Y-%m-%d") $(cat README | wc -w)" >> words.csv

If you run it daily you'll get a CSV file with a line for each day

  • This wasn't exactly what I was looking for. What I'd need is a tool for tracking and plotting all the words, ie. the total amount of words, in my project. For example, the former sentence has 22 words. – abrotherus Jan 30 '15 at 17:07
  • cat *.tex | wc -w will count all the words in all tex files. I've updated the answer. – Dmitry Barashev Jan 30 '15 at 17:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.