Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Shell script to convert binary to hex
# Read either the first argument or from stdin (
cat "${1:-/dev/stdin}" | \
# Convert binary to hex using xxd in plain hexdump style
xxd -ps | \
# Put spaces between each pair of hex characters
sed -E 's/(..)/\1 /g' | \
# Merge lines
tr -d '\n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment