I'd like to know the equivalent of
cat inputfile | sed 's/\(.\)/\1\n/g' | sort | uniq -c
presented in https://stackoverflow.com/questions/4174113/how-to-gather-characters-usage-statistics-in-text-file-using-unix-commands for production of character usage statistics in text files for binary files counting simple bytes instead of characters, i.e. output should be in the form of
18383 57
12543 44
11555 127
8393 0
It doesn't matter if the command takes as long as the referenced one for characters.
If I apply the command for characters to binary files the output contains statistics for arbitrary long sequences of unprintable characters (I don't seek explanation for that).
| sort -n
and| sort -n -r
for descending order respectively (sorting was not part of the question). Sorting might be done better... – Kalle Richter Sep 23 '14 at 17:28sort -n
here makes a lot more sense. Answer updated. – Stéphane Chazelas Jun 16 '15 at 13:44