bytes: count bytes

This simple C program counts the frequency of each byte in standard input or in one or more files. You can specify the names of the files to read as command-line arguments or as a list in standard input or in a file. You can customize the format of the output.

Download

Download a compressed archive file:

Unpack

Unpack the archive file. For example:

Compile

  1. Go to the bytes directory. For example: cd bytes
  2. Compile and link the executable file. For example:
    • With make: make
    • Without make: gcc -o bytes bytes.c

Examples

Count the bytes in standard input

echo test | ./bytes

10 '\n' 1
101 'e' 1
115 's' 1
116 't' 2
5

List the bytes that occur at least twice in standard input sorted by frequency

echo The quick brown fox jumps over the lazy dog. | ./bytes -s -n 2 -b '"' -f '%B%Q%E' -e '"\n'

" oehru"