I've to extract the number of words using each letter of the alphabet from A to Z. The script that i've to create create take as parameter the name of the dictionary file to analyze and will be used like this ./langstat.sh dico.txtI tried few things like this :    #!/bin/bash    cat ~/dico.txt | grep -o A | wc -lThe problem is that it gives me the number of A into all the file, but I want to know only the number of word having a A into.Could you give me a hand please?
A batch that cout the number of occurrences
bash;shell;shell script;grep;wc
You could use this instead:for c in {A..Z}; do  echo -n $c:   tr ' ' '\n' < dico.txt | grep $c | wc -ldoneIt works as follows: The for loop runs through each character from A to Z. tr replaces all spaces with newlines, so every word has its own line. Then grep searches for the character in the word an prints it if the character is found. wc counts those lines.