#!/bin/sh
[ -z "$1" -o -z "$2" ] && { echo "$0 infile outfile"; exit 1; }
[ -z "$EDITOR" ] && { echo "\$EDITOR must be defined"; exit 1; }

tmpfile=$(mktemp) || exit 1
infile="$1"
outfile="$2"

od -Ax -tx1 "$infile" | head -n -1 > $tmpfile
$EDITOR "$tmpfile"
/bin/echo -ne $(tr -s ' ' < "$tmpfile" | cut -d' ' -f2-17 | awk '{for (i=1; i<=NF; i++) printf "\\x%s", $i}') > $outfile
rm "$tmpfile"
