Skip to content

Instantly share code, notes, and snippets.

@jfdm
Created April 21, 2021 11:07
Show Gist options
  • Save jfdm/3a4c6d37cb0f8679bc213fbdcc5e2a01 to your computer and use it in GitHub Desktop.
Save jfdm/3a4c6d37cb0f8679bc213fbdcc5e2a01 to your computer and use it in GitHub Desktop.
Count words in a rebuttal, and show first n words that are not blockquotes and headings.
#!/bin/bash
# $1 first n words
# $2 the rebuttal.
echo "## WC"
grep -vE -e "^>" $2 | grep -vE -e "^#" | uniq | wc -w
echo ""
echo "## TeX Count"
grep -vE -e "^>" $2 | uniq | texcount -1 -
echo "## First $2 words"
grep -vE -e "^>" $2 | grep -vE -e "^#" | gawk -v c=$1 -v RS='[[:space:]]+' -- 'NR<=c{ORS=(NR<c?RT:"\n");print}' -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment