Skip to content

Instantly share code, notes, and snippets.

@GregTonoski
Created July 6, 2023 08:16
Show Gist options
  • Save GregTonoski/08739025108aa3f5953a4312d0184a31 to your computer and use it in GitHub Desktop.
Save GregTonoski/08739025108aa3f5953a4312d0184a31 to your computer and use it in GitHub Desktop.
Display file content as hexadecimal string
#!/bin/bash
# file_as_hex.bash: display file content as hexadecimal string.
# Examples:
# $ bash file_as_hex.bash input_file.bin
export LC_ALL=C
exec 7< $1
while IFS= read -n 1 -d '' -r -u 7; do
printf "%02X" "'$REPLY"
done
exec 7<&-
printf "\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment