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.
Linux command to retrieve a byte range from a file
command-line-interfacelinux
Related Topic
- Linux – How to Automatically Add New Host to known_hosts
- Linux – How to display certain lines from a text file in Linux
- Linux – How to Determine Best Byte Size for dd Command
- Linux – How to Show Total Progress in Rsync
- Linux – How to open a file with line numbers displayed from the command line in ‘vi’
- Linux – Unix / Linux command to count lines per second from stdin
- Linux – iptables destination NAT from one range to another
- Linux – How does one keep a file’s timestamp (date modified) after a logrotate
Best Answer
The DareDevil of the Unix commands,
dd
to the rescue!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 ifibs
harms the performance, I hope not.