I need to merge chunks from a few but large files. Each line contains the file name and byte offsets.
# file begin end foo/a 11970 12010 foo/a 22995 23035 foo/b 45090 45130 foo/b 46035 46075 foo/b 48150 48190 foo/c 16200 16240 foo/c 17550 17590 foo/c 18540 18580 foo/c 26730 26770 foo/c 34245 34285
The extraction could use
tail -c and
head -c, but this would reopen the same file many times, slowing down the process. The unique solution I thought of was coding a program that seeked to the beginning of each chunk and printed until the end, opening each file only once.
Do you have any suggestion?