How to count the number of occurrence of words from multiple files?

File 1

aaa
bbb
ccc

File 2

aaa
xxx
zzz
bbb

File 3

aaa
bbb
xxx

Output:

aaa 3
bbb 3
ccc 1
xxx 2
zzz 1

Thanks~

perl -ne 'chomp; $x{$_}++; END{for(sort keys %x){print "$_ -> $x{$_}\n"}}' file1 file2 file3
sort File* | uniq -c 

i get it. XD

Try this one

cat File* |sort |uniq -c

Hi,

You can try this too :slight_smile:

awk '{a[$0]++;}END{for(i in a){print i"="a;}}' File*

Thanks,
Ranga:)