I need to efficiently count every character of an arbitrary file by its character CLASS (as defined by the BASH man page); i.e. [[:alnum:]], [[:alpha:]], [[:ascii:]], [[:blank:]], [[:cntrl:]], [[:digit:]], [[:graph:]], [[:lower:]], [[:print:]], [[:punct:]], [[:space:]], [[:upper:]], [[:word:]] and [[:xdigit:]]Once the file is processed, display on a single line the resulting counts for each, even when zero.Web searches have not been fruitful in finding something along these lines.The arbitrary file (/tmp/f1.txt) will contain a variety of diverse text/data.I am not looking to process ELF binaries nor UniCode (or any form of multi-byte) content.I am not concerned about line count (CR and/or LF), only fixated on accumulating a count of each 'character' in the target file by the above classes.I intend for this to end up as a standard function() in a larger bash script.  Bash/sed/awk and the like are desired; while perl/python/ruby not so much.Sample data files could be:Zero bytes, i.e. no content at all.A single characterA single wordMultiple words separated by whitespaceMultiple lines interspersed with whitespace and/or CarriageReturns and/or LineFeeds.For multiline files there might not be a CR or LF to signify the end of the last line (yet all characters should still be counted).
Couting all characters by BASH character class
bash;shell script;text processing