#!/usr/bin/env bash set -e if [ $# -lt 1 ]; then echo "Usage: $0 input.hex [output.bin]" exit 1 fi input="$1" if [ $# -ge 2 ]; then output="$2" else output="${input%.*}.bin" fi perl -ne 's/#.*//; print pack("H*", $_ =~ s/\s+//gr)' "$input" > "$output" echo "Wrote $output"