Bash script to count the frequency of each word in a text file

Linux shell — text processing — Write a bash script to count the frequency of each word in a text file

Explanation:

  • cat: open content
  • tr: replace all space with a newline ( all words will be as one line )
  • sed: delete blank lines in the file
  • tr: convert all to lowercase
  • sort: sort alpha
  • uniq: count word
  • sort: sort with reverse order
  • awk: print by format we want

Leave a Reply

avatar
  Subscribe  
Notify of