mercredi 2 juillet 2014

Can brace expansions and grep be used together in linux


Vote count:

0




I am trying to count how many times each ASCII printable character is present in a file. I thought a good way to do this might be to list the printable characters in a { } enclosed list, and use grep on each item within the braces. An example code is below. I would like to expand the char list to include all 64 ASCII printable characters. I cannot figure out how to get the code to read and use each characters between the braces separately. I would really like to output a file in the format "character\tcharacterCount". Any suggestions?



char={" ",!,\",#,"\$"}
cat PHRED_scores.txt | grep -e "$char" | wc -m


asked 14 secs ago






Aucun commentaire:

Enregistrer un commentaire