Convert a hexdump
Output to a Binary¶
Convert a file to ASCII-only (good for transmitting via a UART). hexdump
can be found in a lot of places, making it more suitable than xxd
for portability reasons. The -C
can be omitted to reduce the transfer size (and thus time), without changing the regex below.
hexdump -Cv \
< "${FILE}" \
> "${FILE%.*}.hex"
Convert the hex dump back to a binary:
cat "${FILE}" \
| sed -r \
-e 's/[^ ]+ *//' \
-e 's/ +\|.*\|$//' \
-e 's/([0-9a-f]{2})([0-9a-f]{2})/\2\1/g' \
-e 's/ //g' \
| xxd -r -p \
> "${FILE%.*}.bin"