Count occurences of string

Hi,

Please help me in finding the number of occurences of the string.

Example: Apple, green, blue, Apple, Orange, green, blue are the strings can be even in the next line.

The o/p should look as:
Word Count
----- -----
Apple 2
green 2
Orange 1
blue 2

Thanks

assignment ?

read about the grep command ( read the argument c )
read about the for loop or while loop

1 Like

Thanks but i found even simpler solution than that

Rather than going for the grep, while and for loops

I am expecting an answer more like

tr -s " ," "\n" < <file_name> | sort | uniq -c

Anyways thanks for the reply :slight_smile: