Niall O Broin said:
> 00000000: 0005 1607 0001 0000 0000 0000 0000 0000 ................
> 00000010: 0000 0000 0000 0000 0005 0000 0002 0000 ................
> 00000020: 024d 0000 ef15 0000 0003 0000 0056 0000 .M...........V..
> 00000030: 0016 0000 0004 0000 0155 0000 0000 0000 .........U......
I like the one from an edition of the Camel book, short, simple,
and doesn't need to be rebuilt on every platform. Here it is:
#!/usr/bin/perl
# Usage: xdump [file]
open(STDIN,$ARGV[0]) || die "Can't open $ARGV[0]: $!\n"
if $ARGV[0];
# Do it optimally as long as we can read 16 bytes at a time.
while (($len = read(STDIN,$data,16)) == 16) {
@array = unpack('N4', $data);
$data =~ tr/\0-\37\177-\377/./;
printf "%8.8lx %8.8lx %8.8lx %8.8lx %8.8lx %s\n",
$offset, @array, $data;
$offset += 16;
}
# Now finish up the end a byte at a time.
if ($len) {
@array = unpack('C*', $data);
$data =~ y/\0-\37\177-\377/./;
for (@array) {
$_ = sprintf('%2.2x',$_);
}
push(@array, ' ') while $len++ < 16;
$data =~ s/[^ -~]/./g;
printf "%8.8lx ", $offset;
printf "%s%s%s%s %s%s%s%s %s%s%s%s %s%s%s%s %s\n",
@array, $data;
}
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!