Skip to content

Instantly share code, notes, and snippets.

@hdznrrd
Last active December 16, 2015 09:28
Show Gist options
  • Save hdznrrd/5412814 to your computer and use it in GitHub Desktop.
Save hdznrrd/5412814 to your computer and use it in GitHub Desktop.
condense duplicate rows of XVI32 hexeditor text printouts
#/usr/bin/perl
#
# condense duplicate rows of XVI32 hexeditor text printouts
#
# usage:
# cat file.txt | perl condense.pl
#
# sample output:
# 000000704: 53 0A 70 0D 08 00 A8 34 00 20 00 00 00 00 00 00
# 000000720: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
# ... : ... ignored 1473 similar line(s)
# 000024304: 53 0E 00 00 00 00 00 00 00 00 00 00 00 12 00 00
# 000024320: 00 00 00 00 00 00 01 00 58 02 00 00 00 00 00 00
# 000024336: 40 01 00 00 C0 6F 2A 00 75 04 00 00 77 02 00 00
$i = 0;
@dr = ();
@ar = ();
while(<>) {
s/[\r\n]+//g; # bad windows. bad.
if(/:/) {
($addr,$data) = split /: /;
if($dr[-1]!=$data) {
if($i>0) { push @ar,"... "; push @dr,"... ignored $i similar line(s)"; $i=0; }
push @ar, $addr; push @dr, $data;
} else { ++$i; }
}
}
map { print "$ar[$_]: $dr[$_]$/" } 0..$#ar;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment