Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show the first x bytes using hexdump?

Tags:

linux

bash

unix

I have two files and I want to see if the first 40 bytes are similar. How can I do this using hex dump?

like image 729
OHHH Avatar asked Jan 28 '15 03:01

OHHH


1 Answers

If you are using the BSD hexdump utility (which will also be installed as hd, with a different default output format) then you can supply the -n40 command line parameter to limit the dump to the first 40 bytes:

hexdump -n40 filename

If you are using the Posix standard od, you need a capital N. You might find the following invocation useful:

od -N40 -w40 -tx1 -Ax filename

(You can do that with hexdump, too, but the format string is more work to figure out :) ).

like image 158
rici Avatar answered Oct 27 '22 11:10

rici