Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash : Get the bytes at offset for length

I was wondering how I could retrieve bytes from a files given an offset and a length.

I came to the following line : hexdump -n 4 -s 0x11C myFile

I get the following : Not good enough, I don't need the offset.

000011c 00 00 8c d0

Second try :

hexdump -n 4 -s 0x11C -e '"%x\n"' myFile

I get the following : better but wrong endianness.

d08c0000

So how can I do it ? I know I could parse it with sed, but isn't there a «cleaner» solution that that ?

like image 503
Matthieu Riegler Avatar asked Jul 11 '26 10:07

Matthieu Riegler


1 Answers

hexdump -n 4 -s 0x11C -e '4/1 "%x " "\n"' myFile

(My version of hexdump does not produce one-byte hex output as in your first example. Did you use some other command option?)

like image 105
rici Avatar answered Jul 14 '26 04:07

rici