From 95155316462b45d7ee3baa64f28abe7b6d1be024 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Mon, 24 Nov 2008 19:43:46 +0000 Subject: [PATCH 1/1] quick-and-dirty script to reverse the output of od --- revod | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 revod diff --git a/revod b/revod new file mode 100755 index 0000000..bca78c7 --- /dev/null +++ b/revod @@ -0,0 +1,33 @@ +#! /usr/bin/perl -w +use strict; + +# Convert the output of 'od -tx1 -Ax' back to binary. The input is expected +# to look like this: +# +# 000000 eb 58 90 4d 41 4b 45 42 4f 4f 54 00 02 08 40 00 +# 000010 01 00 00 00 00 f8 00 00 20 00 40 00 00 00 00 00 +# [...] + +binmode STDOUT; + +my $index = 0; +my $prevblock; +while (<>) { + chomp; + next if $_ eq '*'; + if (s/^([a-z0-9]+)(?:\s+|$)//) { + my $lineindex = hex($1); + while ($lineindex > $index) { + die "no previous block!" unless defined $prevblock; + for my $hex (split ' ', $prevblock) { + print chr(hex($hex)); + ++$index; + } + } + } + for my $hex (split) { + print chr(hex($hex)); + ++$index; + } + $prevblock = $_; +} -- 2.30.2