Advertisement
viktorstrate

Latex character count

Dec 16th, 2018
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.93 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. documents=$(find . | grep -e "\.tex$")
  4. sum=0
  5. sum_space=0
  6.  
  7. for doc in $documents
  8. do
  9.     echo "Reading $doc"
  10.     letters_text=$(/Library/TeX/texbin/texcount -char $doc | grep 'Letters in text' | grep -o -E '[0-9]+')
  11.     letters_headers=$(/Library/TeX/texbin/texcount -char $doc | grep 'Letters in headers' | grep -o -E '[0-9]+')
  12.  
  13.     words_text=$(/Library/TeX/texbin/texcount $doc | grep 'Words in text' | grep -o -E '[0-9]+')
  14.     words_headers=$(/Library/TeX/texbin/texcount $doc | grep 'Words in headers' | grep -o -E '[0-9]+')
  15.  
  16.     letters=$(($letters_text+$letters_headers))
  17.     words=$(($words_text+$words_headers))
  18.  
  19.     sum=$(($sum+$letters))
  20.     sum_space=$(($sum_space+$letters+$words))
  21. done
  22.  
  23. echo "--- Results ---"
  24. echo "The total sum of characters (excluding space): $sum"
  25. echo "The total sum of characters (including space): $sum_space"
  26. pages=$(echo "print $sum_space/2400" | perl)
  27. echo "Pages: $pages"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement