Skip to content

Instantly share code, notes, and snippets.

@stevenalexander
Created May 4, 2017 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevenalexander/7a122fdf6a6c324f6ceb345cda450c70 to your computer and use it in GitHub Desktop.
Save stevenalexander/7a122fdf6a6c324f6ceb345cda450c70 to your computer and use it in GitHub Desktop.
Getting word count for site from nunjucks/jinja2 template HTML files
# from views directory
# create .out files with HTML tags stripped
find . -name '*.html' -exec sh -c 'sed -e "s/<[^>]*>//g" $1 > $1.out' -- {} \;
# create .out.bout files with nunjucks/jinja2 tags stripped
find . -name '*.html.out' -exec sh -c 'sed -e "s/{[^}]*}//g" $1 > $1.bout' -- {} \;
# word count
find . -name '*.html.out.bout' | xargs wc -w
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment