Skip to content

Instantly share code, notes, and snippets.

@themadinventor
Created January 28, 2015 22:18
Show Gist options
  • Select an option

  • Save themadinventor/3b0b097fb5aa50e23a0d to your computer and use it in GitHub Desktop.

Select an option

Save themadinventor/3b0b097fb5aa50e23a0d to your computer and use it in GitHub Desktop.
Convert binary file (blob) to c-style array.
bin2c() {
output=${2-/dev/stdout}
echo -n "uint8_t data[] = {" > "$output"
hexdump -v -e '"0x" 1/1 "%02X" ", "' $1 >> "$output"
echo "};" >> "$output"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment