Last active
June 6, 2018 11:04
-
-
Save nilsreiter/a9f0fe75fa4d21c27bcce089583d4c63 to your computer and use it in GitHub Desktop.
Count words in plain text file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This snippet can be used on the command line (tested on a Mac) to get a quick list of word frequencies in the file FILENAME. | |
# Counting will be done case-insensivitely, i.e., differently cased words will be counted together. | |
# The result will be written in the file stats.csv (or any other that you give at the end) in the form of a space-separated table | |
cat FILENAME | tr '[[:punct:][:space:]]' '\n' | sort | uniq -ci | sort -nr | tail -n +2 > stats.csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment