I know that
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.
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.
I know this is old, and asked for a "linux" command in the title, but python is perfect for this and comes with most linux distributions. It's as easy as this:
python -c 'f=open("myfile.txt","rb");f.seek(100);print(f.read(100));f.close()' | SomeOtherProgram
f.seek(n,0) goes n bytes from the start of the program, and
f.read(n) reads the number of bytes you want.
I've not found any other options that make it that easy.