Re: [dev] a suckless hex editor

From: pancake <pancake_AT_youterm.com>
Date: Fri, 13 Nov 2015 21:42:11 +0100

Use rm -f



> On 13 Nov 2015, at 20:54, Dimitris Papastamos <sin_AT_2f30.org> wrote:
>
>> On Fri, Nov 13, 2015 at 02:52:17PM -0500, Greg Reagle wrote:
>> 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"
>
> echo -e is evil, use printf(1)
>
Received on Fri Nov 13 2015 - 21:42:11 CET

This archive was generated by hypermail 2.3.0 : Fri Nov 13 2015 - 21:48:08 CET