Sample Header Ad - 728x90

Hexdump prints beyond EOF with format string

0 votes
0 answers
50 views
I am in the process of writing a xxd -i like script. For that I need the hex dump of a file. I am using the following command for that: hexdump -v -e '8/1 "0x%02x," "\n"' this works fine when the amount of bytes is divisible by 8: 0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a, However, when the amount of bytes is not divisible by 8, it still formats non-existing bytes: 0x89,0x50,0x4e,0x47,0x ,0x ,0x ,0x , Is it either possible to zero-fill the bytes (i.e. make hexdump report null-bytes after eof) or simply "cancel" the formatting after the last real byte?
Asked by Raildex (101 rep)
Mar 6, 2025, 08:57 PM