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
Compile
- Download one of the archive files.
-
Unpack the archive file. For example:
- To unpack bytes.tar.xz: tar -xJf bytes.tar.xz
- To unpack bytes.tar.gz: tar -xzf bytes.tar.gz
- To unpack bytes.zip: unzip -q bytes.zip
- Go to the bytes directory. For example: cd bytes
-
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"