I've used the below command to count the number of words in a file:
tr ' ' '\n' < Filename | grep -c "WORD"
This returns the word list with counter. Now I want to count the number of words of a particular length. For example, given a file with these contents:
employee paresh emp employee jayesh hitesh
When I run the shell script with argument 6
, it should display/count words with 6 characters (paresh
, jayesh
, and hitesh
, with count 3
). How can I do that?