in reply to Re: hexdump -C
in thread hexdump -C
But, as I went to create an example for you, I realized I misunderstood the '*' behavior. It prints one full line of 00 00 00 ... and then the '*' means "repeat the previous line". I'd only ever seen it replace zeroes with '*' because that's the most likely repetition to appear in data files.
$ perl -E 'say "\0"x64 ."A"x64' | hexdump -C 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |......... +.......| * 00000040 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 |AAAAAAAAA +AAAAAAA| * 00000080 0a |.| 00000081
Combining everyone's ideas, I now get:
sub hexdump($data) { $data =~ s/\G(.{1,16})(\1+)?/ sprintf "%08X %-50s|%s|\n%s", $-[0], "@{[unpack q{(H2)8a0(H2)8},$1]}", $1 =~ y{ -~}{.}cr, "*\n"x!!$+[2] /segr . sprintf "%08X", $+[0] }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: hexdump -C
by harangzsolt33 (Deacon) on Oct 15, 2025 at 14:07 UTC | |
by ikegami (Patriarch) on Oct 15, 2025 at 14:15 UTC | |
by harangzsolt33 (Deacon) on Oct 15, 2025 at 14:25 UTC | |
by ikegami (Patriarch) on Oct 15, 2025 at 14:28 UTC | |
by NERDVANA (Priest) on Oct 16, 2025 at 02:58 UTC |