Tips for using hexdump

Source: Internet
Author: User

During development, you often need to view the content of non-text files. The most common hexadecimal viewer is hexdump. Hexdump seems simple, but it still has some tips.

The text file tmpfile is used as an example:

Click (here) to fold or open

    Happy New Year! Happy New Year!
    Happy New Year! 1) The simplest way
    Hexdump testfile

    0000000 6148 7070 2079 654e 2077 6559 7261 0a21
    *
    0000030

    This method takes two bytes as a group, and the order depends on the local byte order. For example, in the x86 architecture, it is displayed in the blittle-endian mode, and it looks very difficult.
    For example, the first line is translated into an ascii code:
    6148 7070 2079 2077 654e 6559 7261 0a21
    AH pp y Ne w e AE! R

    To avoid this situation, we need to use the following "view in byte mode"

    2) view in bytes
    Hexdump-C testfile-s skip-n number

    00000000 48 61 70 70 79 20 4e 65 77 20 59 65 61 72 21 0a | Happy New Year !. |
    *
    00000030

    In this way, there will be no problem with the byte order, and the hexadecimal and ascii code can be displayed at the same time. However, the problem is that if the content of several rows is the same, the last few lines will be omitted, which sometimes causes trouble. How can we avoid omitting it?

    3) do not omit
    Hexdump-v testfile

    0000000 6148 7070 2079 654e 2077 6559 7261 0a21
    0000010 6148 7070 2079 654e 2077 6559 7261 0a21
    0000020 6148 7070 2079 654e 2077 6559 7261 0a21
    0000030

    If we omit it, But it returns to the old road where two bytes are displayed, we need to combine the two methods.

    4) display in byte mode and do not omit
    Hexdump-Cv testfile

    00000000 48 61 70 70 79 20 4e 65 77 20 59 65 61 72 21 0a | Happy New Year !. |
    00000010 48 61 70 70 79 20 4e 65 77 20 59 65 61 72 21 0a | Happy New Year !. |
    00000020 48 61 70 70 79 20 4e 65 77 20 59 65 61 72 21 0a | Happy New Year !. |
    00000030

    Now we can see more. It is displayed in a single byte format and will not be omitted. But sometimes the file is very large. We only want to check one of them. How can this problem be solved?

    5) display a Section
    Hexdump-Cv testfile-s skip-n number

    Fireaxe $ hexdump-Cv tmp.txt-n 1
    00000000 48 | H |
    00000001

    Fireaxe $ hexdump-Cv tmp.txt-n 2
    00000000 48 61 | Ha |
    00000002

    Fireaxe $ hexdump-Cv tmp.txt-n 3
    00000000 48 61 70 | Hap |
    00000003
    Fireaxe $ hexdump-Cv tmp.txt-s 1-n 1
    00000001 61 | a |
    00000002
    Fireaxe $ hexdump-Cv tmp.txt-s 2-n 1
    00000002 70 | p |
    00000003
    Fireaxe $ hexdump-Cv tmp.txt-s 3-n 1
    00000003 70 | p |
    00000004

    OK. You can control the entire display process ~~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.