20 lines
No EOL
294 B
Bash
Executable file
20 lines
No EOL
294 B
Bash
Executable file
#!/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" |