#!/usr/bin/perl # Convert hexdump -C like output back to binary. Supports * lines, which # xxd -r does not (this is the reason for this script). Assumes good input. use strict; use warnings; my ($off, $line, $asterisk); while (<>) { if (/^([[:xdigit:]]{2,}0)\s+((?:[[:xdigit:]]{2}\s+){1,16})/) { if (defined($asterisk)) { my $nlines = (hex($1) - hex($off)) / 16 - 1; print map { chr hex } split /\s+/, $line x $nlines; undef $asterisk; } print map { chr hex } split /\s+/, $2; $off = $1, $line = $2; } elsif (/^\*/) { $asterisk = 1; } else { last; } }