shellbinary

How to view files in binary from bash?


I would like to view the contents of a file in the current directory, but in binary from the command line. How can I achieve this?

For example, something like this:

$ cat test
Hello, world!

$ binarycat test
01001000 01100101 01101100 01101100 01101111 00101100
00100000 01110111 01101111 01110010 01101100 01100100
00100001 00001010

Solution

  • xxd does both binary and hexadecimal.

    bin:

    xxd -b file
    

    hex:

    xxd file