I am trying to count a special character in several thousand files and sort the result according to the number the character occured in each files.
files:
1.txt
2.txt
3.txt
files look like:
ABCDEFGHABBBACF
I want the number of B in each file and a result file that lists the occurence of B in each file.
result:
3.txt 4
1.txt 1
2.txt 3
I have tried:
ls *txt | xargs grep -c "B"
from there I want to pipe the output into 'sort'
But 'grep -c' gives only the number of lines, not the number of characters.