editing and viewing binary files under Linux-

Source: Internet
Author: User

editing and viewing binary files under Linux

One, the software to view the binary files under Linux:

XXD (default 2-binary)

Hexdump (default 16 binary, can be transferred to other binary)

OD (default 8-binary, can be transferred to other binary)

Second, the editor:

1, Biew

2, HexEdit

3. Vim

Vim to edit a binary file. Vim is not designed for this purpose, so there are some limitations. But you can read
Take a file, change a character, and then save it to disk. The result is that your file is changed only by that one character,
The rest is exactly the same as the original one.
To ensure that VIM does not use its clever tricks in the wrong place, start Vim with the "-B" parameter:
Vim-b datafile
This parameter sets the ' binary ' option. Its role is to exclude all unintended side effects. For example, ' TextWidth '
Set to zero so that text lines are not allowed to be typeset. Also, files are read in Unix file format.
Binary mode can be used to modify a program's message messages. Be careful not to insert or delete any characters, which will cause the program to be shipped
The line is faulty. Use the "R" command to enter the replacement mode.
Many of the characters in the file are not displayed. Display their values in HEX format:
: Set Display=uhex
Alternatively, you can use the command "GA" to display the character values under the cursor. When the cursor is over a character,
The output of the command looks like this:
1b, Hex, octal 033
There may not be so many line breaks in the file. You can turn off the ' wrap ' option to get an overview of the effects:
: Set nowrap
byte position
To find the current byte position in your file, use this command:
G Ctrl-g
Its output is lengthy:
Col 9-16 of 9-16; Line 277 of 330; Word 1806 of 2058; Byte 10580 of 12206
The last two digits are the current byte position in the file and the total number of file bytes. This has taken into account the ' FileFormat '
option causes the effect of a different line break byte.
To move to a specified byte in a file, use the "Go" command. For example, to move to byte 2345:
2345go
Using XXD
A true binary editor is a two-way display of text: binary and hexadecimal format. You can be in Vim
The conversion program "XXD" to achieve this effect. The program is released with Vim.
First edit this file in binary mode:
Vim-b datafile
Now use XXD to convert this file into 16 binary:
:%!xxd
The text looks like this:
0000000:1f8b 0808 39d7 173b 0203 7474 002b 4e49 .... 9..;.. Tt.+ni
0000010:4B2C 8660 eb9c ECAC c462 eb94 345e 2e30 K,.. 4^.0
0000020:373b 2731 0b22 0ca6 c1a2 d669 1035 39d9 7; ' 1. "..... i.59.
Now you can read and edit the text as you wish. Vim treats this information as plain text.
Modifying the hexadecimal section does not result in a change in the part of the character that can be displayed, or vice versa.
Finally, use the following command to convert it back:
:%!xxd-r
Only 16 of the modifications in the binary section will be used. Changes to the right can display text portions that are ignored.



From for notes (Wiz)

editing and viewing binary files under Linux-

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.