Together with hexdump it can be used for editing binary files: First you hexdump the file, then you modify the dump-file in an editor, then you use hex2bin to produce the modified binary file. Because there are so many versions of hexdump out there, which have so many different output-formats, you had better use that one distributed together with hex2bin.
Also, you can use this program to produce binary data to send to a device or to another program. Use option -I for this task.
Each, any or all of these parts can be omitted.
A special case are repetition-lines, which start with an asterisk (*) and may be followed by a decimal(base 10) number.
The last line consists of a semicolon (;) optionally preceded by an Address-field. Anything after this semicolon will be ignored. If no line with semicolon is found till the end of input and option -q is not specified, a warning is shown, but all data-fields are still converted. The reason for issuing the warning at all is that hexdump outputs a semicolon-line at the end, and thus the warning most likely indicates unexpected truncation. In interactive mode (option: -I), this warning is suppressed.
If the first (hex-)number of an input-line is not followed by a colon or semicolon, it will be interpreted as part of the data-field.
0A 7f " \\\aBeep\t" - 04 1b "\0"
which will be converted to a newline(0A), a Delete-char(7F) , a space (first character of string), a backslash(\\), a beep-code(\a), the characters 'B' 'e' 'e' 'p', a tab, an EOF-code, an Esc-code and the Null-byte. Dashes ('-') will be ignored for compatibility with hexdump's output.
The actual number of repetitions can be specified in two ways:
explicitly: if a decimal number follows the asterisk, this number will specify the number of repetitions. (Note: to get a total of e.g. 10 times a chunk, specify 9, because the chunk itself was already output once where it appeared in the input.)
implicitly: If no explicit count is specified, the number of repetitions is automatically calculated based on the address-field of the next input line. In this case, an address must be specified there, otherwise an error occurs and conversion is aborted. Even more, if the number of bytes necessary to reach the next specified address is not a multiple of the byte length of the repeated chunk, this is also an error.
Report missing features (in your eyes) to author's address
Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation.