How to view files in binary from bash?

后端 未结 12 1906
北恋
北恋 2020-11-29 14:39

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?

相关标签:
12条回答
  • 2020-11-29 14:59

    If you want to open binary files (in CentOS 7):

    strings <binary_filename>
    
    0 讨论(0)
  • 2020-11-29 14:59

    sudo apt-get install bless

    Bless is GUI tool which can view, edit, seach and a lot more. Its very light weight.

    0 讨论(0)
  • 2020-11-29 15:00

    You can use hexdump binary file

    sudo apt-get install hexdump
    
    hexdump -C yourfile.bin
    
    0 讨论(0)
  • 2020-11-29 15:02
    $ echo -n 'Hello world!' | hd
    00000000  48 65 6c 6c 6f 20 77 6f  72 6c 64 21              |Hello world!|
    0000000c
    
    0 讨论(0)
  • 2020-11-29 15:03
    vi your_filename
    

    hit esc

    Type :%!xxd to view the hex strings, the n :%!xxd -r to return to normal editing.

    0 讨论(0)
  • 2020-11-29 15:09

    xxd does both binary and hexadecimal.

    bin:

    xxd -b file
    

    hex:

    xxd file
    
    0 讨论(0)
提交回复
热议问题