Bash

Word Frequency Count

admin by @admin ADMIN
10m ago
May 31, 2026
Public
0 0 up · 0 down Sign in to vote
Classic shell one-liner: split text into words, sort, count uniques, sort by count. Useful for log analysis, content audits, and tag-cloud-style summaries.
Bash
Raw
# Most common words in a text file
tr -c '[:alnum:]' '\n' < article.txt | \
    tr '[:upper:]' '[:lower:]' | \
    grep -v '^$' | \
    sort | uniq -c | sort -rn | head -20

# Most common HTTP status codes in an access log
awk '{print $9}' access.log | sort | uniq -c | sort -rn

# Most common IPs hitting a 500
awk '$9 == 500 {print $1}' access.log | sort | uniq -c | sort -rn | head
Tags

Save your own code snippets

Create a free account and build your private vault. Share publicly whenever you want.