find-bfile(2)find-bfile - Load a file as binary data
find-rfile - Load a file as binary data (reduced)
n find-bfile "file-name" (C-x 9)
n find-rfile "file-name"
find-bfile and find-rfile both load a file as binary data, providing binary editing capabilities. The commands operate as command find-file(2) except that they load the given file with binary(2m) or rbin(2m) mode set.
find-bfile, which uses binary mode, loads any file and converts every 16 bytes into a line of text giving the hex address of the current position in the file, the bytes as hexadecimal numbers and all printable characters at the end of the line (all non-printable characters are displayed as a '.'). However, This format makes it memory hungry in that every 16 bytes of the file requires a 78 character line (approximately 5 times more memory!).
find-rfile, which uses rbin mode, loads any file and converts every 256 bytes into a line of text containing only 2 hexadecimal numbers per byte leading to a line length of 512 characters. This format greatly reduces the memory required (approximately 2 times more memory) making it ideal for large binary file editing.
The extension of a file loaded using binary or rbin mode is ignored with respect to file hooks (See add-file-hook(2)). Instead the fhook-binary or fhook-rbin command is always executed if it exists.
Each line of text may be edited, providing that the basic format of every line remains the same, the altered file may be written out, providing full binary editing capabilities.
Given a single line MSDOS file:-
Live long and prosper.
When loaded in using find-bfile will produce the following 2 line buffer:-
00000000: 4C 69 76 65 20 6C 6F 6E 67 20 61 6E 64 20 70 72 | Live long and pr 00000010: 6F 73 70 65 72 2E 0D 0A 1A | osper....
Note the "0D 0A 1A" at the end, this is due to MSDOS's "\n\r" carriage returns and ^Z file termination, these characters are unprintable and are shown as '.' at the end of the line. The basic form of a binary file is:-
AAAAAAAA: XX XX XX XX .... |
When saving a binary file, only the text between the ':' and '|' is considered and it may contain any number of hexadecimal numbers. The given file could be made UNIX compatible by editing the buffer to:-
00000000: 4C 69 76 65 20 6C 6F 6E 67 20 61 6E 64 20 70 72 | Live long and pr 00000010: 6F 73 70 65 72 2E 0D | osper....
If the word "long" is required to be removed, the following would not work:-
00000000: 4C 69 76 65 20 6C 6F 6E 67 20 61 6E 64 20 70 72 | Live and pr 00000010: 6F 73 70 65 72 2E 0D 0A 1A | osper....
The ASCII end letters are ignored, instead the following operation must be performed which removes the characters from the binary representation:-
00000000: 4C 69 76 65 20 61 6E 64 20 70 72 | Live long and pr 00000010: 6F 73 70 65 72 2E 0D 0A 1A | osper....
One could be nasty by doing the following:-
00000000: 4C 69 76 65 20 73 68 6F 72 74 20 61 6E 64 20 | 00000010: 64 6F 6E 27 74 20 70 72 6F 73 70 65 72 2E 0D 0A 1A |
("Live short and don't prosper"). If this file was then loaded using find-rfile, the following single line buffer would be created:-
4C6976652073686F727420616E6420646F6E27742070726F737065722E0D0A1A
(c) Copyright JASSPA 2025
Last Modified: 2024/05/21
Generated On: 2025/09/29