Okay then. It no longer depends on xxd. It depends on od for the hex dump (works with both GNU od and sbase od) and echo, awk, tr, cut for the reverse hex dump.
#!/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"

Reply via email to