Linux command to retrieve a byte range from a file

command-line-interfacelinux

I know that head and tail can take -c option to specify a byte offset. I'm looking for a way to efficiently extract a byte range from a large log file.

Best Answer

The DareDevil of the Unix commands, dd to the rescue!

dd if=yourfile ibs=1 skip=200 count=100

That would start from byte 200 and show 100 next bytes, or in other words, bytes 200-300. ibs means dd only reads one byte at a time instead of the default 512 bytes, but still writes out in default 512 byte chunks. Go and see if ibs harms the performance, I hope not.