Sample Header Ad - 728x90

Make xxd break lines

2 votes
1 answer
1193 views
For showing the content of a file with both formatted text **and** binary data inside in another post on SE I couldn't decide on wheather to show the ASCII rendered output or a the xxd output. As a middle course I thought about a hexdump that **does** respect newlines. (Other) example:
00000000: 636f 6d6d 6974 2031 3933 0074 7265 6520  commit 193.tree
00000010: 3331 3439 3530 3736 3263 6561 3232 3364  314950762cea223d
00000020: 3230 6233 3931 6235 3162 3336 3463 6134  20b391b51b364ca4
00000030: 3165 3636 3234 3931 0a61 7574 686f 7220  1e662491.author
00000040: 4578 616d 706c 6520 5573 6572 203c 6578  Example User  149
00000070: 3831 3236 3633 3320 2b30 3230 300a 636f  8126633 +0200.co
00000080: 6d6d 6974 7465 7220 4578 616d 706c 6520  mmitter Example
00000090: 5573 6572 203c 6578 616d 706c 6575 7365  User  1498126633
000000c0: 2b30 3230 300a 0a69 6e69 740a            +0200..init.
would become
00000000: 636f 6d6d 6974 2031 3933 0074 7265 6520  commit 193.tree
00000010: 3331 3439 3530 3736 3263 6561 3232 3364  314950762cea223d
00000020: 3230 6233 3931 6235 3162 3336 3463 6134  20b391b51b364ca4
00000030: 3165 3636 3234 3931 0a                   1e662491.
                                
00000030:                       61 7574 686f 7220           author
00000040: 4578 616d 706c 6520 5573 6572 203c 6578  Example User  149
00000070: 3831 3236 3633 3320 2b30 3230 300a       8126633 +0200.
                                            
00000070:                                    636f                co
00000080: 6d6d 6974 7465 7220 4578 616d 706c 6520  mmitter Example
00000090: 5573 6572 203c 6578 616d 706c 6575 7365  User  1498126633
000000c0: 2b30 3230 300a                           +0200.

000000c0:                0a                              .

000000c0:                  69 6e69 740a                   init.
or
00000000: 636f 6d6d 6974 2031 3933 0074 7265 6520  commit 193.tree
00000010: 3331 3439 3530 3736 3263 6561 3232 3364  314950762cea223d
00000020: 3230 6233 3931 6235 3162 3336 3463 6134  20b391b51b364ca4
00000030: 3165 3636 3234 3931 0a                   1e662491.
00000030:                       61 7574 686f 7220           author
00000040: 4578 616d 706c 6520 5573 6572 203c 6578  Example User  149
00000070: 3831 3236 3633 3320 2b30 3230 300a       8126633 +0200.
00000070:                                    636f                co
00000080: 6d6d 6974 7465 7220 4578 616d 706c 6520  mmitter Example
00000090: 5573 6572 203c 6578 616d 706c 6575 7365  User  1498126633
000000c0: 2b30 3230 300a                           +0200.
000000c0:                0a                              .
000000c0:                  69 6e69 740a                   init.
or
00000000: 636f 6d6d 6974 2031 3933 0074 7265 6520  commit 193.tree
00000010: 3331 3439 3530 3736 3263 6561 3232 3364  314950762cea223d
00000020: 3230 6233 3931 6235 3162 3336 3463 6134  20b391b51b364ca4
00000030: 3165 3636 3234 3931 0a                   1e662491.
                                61 7574 686f 7220           author
00000040: 4578 616d 706c 6520 5573 6572 203c 6578  Example User  149
00000070: 3831 3236 3633 3320 2b30 3230 300a       8126633 +0200.
                                             636f                co
00000080: 6d6d 6974 7465 7220 4578 616d 706c 6520  mmitter Example
00000090: 5573 6572 203c 6578 616d 706c 6575 7365  User  1498126633
000000c0: 2b30 3230 300a                           +0200.
                         0a                              .
                           69 6e69 740a                   init.
or similar
Asked by stuquus (23 rep)
Jun 22, 2017, 11:38 AM
Last activity: Dec 16, 2020, 04:34 PM