This question already has an answer here:
following Convert decimal to hexadecimal in UNIX shell script
I am trying to print only the hex values
from hexdump
, i.e. don't print the lines numbers and the ASCII table.
But the following command line doesn't print anything:
hexdump -n 50 -Cs 10 file.bin | awk '{for(i=NF-17; i>2; --i) print $i}'
Using
xxd
is better for this job:From
man xxd
:First of all, remove
-C
which is emitting the ascii information.Then you could drop the offset with
As an alternative, consider using
xxd -p file.bin
.You can specify the exact format that you want
hexdump
to use for output, but it's a bit tricky. Here's the default output, minus the file offsets:(To me, it looks like this would produce an extra trailing space at the end of each line, but for some reason it doesn't.)