Skip to content

Instantly share code, notes, and snippets.

@HBBisenieks
Created September 22, 2014 18:58
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 HBBisenieks/c771892e3633c32c5085 to your computer and use it in GitHub Desktop.
Save HBBisenieks/c771892e3633c32c5085 to your computer and use it in GitHub Desktop.
Get basic statistics on unique and repeated words from a plaintext file.
#!/bin/bash
echo "$1 is `wc -w $1 | awk '{print $1}'` words long."
echo "It contains `cat $1 | awk '{ for (i=1; i<=NF; i++) print $i }' | sed -e 's/[,.;-*?"]//g' | tr A-Z a-z | sort | uniq | wc -w` unique words."
echo "It contains `cat $1 | awk '{ for (i=1; i<=NF; i++) print $i }' | sed -e 's/[,.;-*?"]//g' | tr A-Z a-z | sort | uniq -d | wc -w` words that are repeated at least once."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment