slice is a minimal, reliable tool for extracting byte ranges from text files, with support for trimming incomplete lines. It is ideal for clean, line-aware chunking of large text files — such as for indexing, archival, or content analysis.
https://github.com/ha1tch/slice

Releases:
https://github.com/ha1tch/slice/releases

Benchmarks:
https://ha1tch.github.io/slice/benchmark_report.html

#foss #unix #linux #slice

GitHub - ha1tch/slice: A small command-line utility to extract a byte slice from any position in a file and optionally trim truncated lines.

A small command-line utility to extract a byte slice from any position in a file and optionally trim truncated lines. - ha1tch/slice

GitHub

@haitchfive

You might want to check some edge cases. What if you pick full lines only and the start position happens to be exactly at the start of a line?

#TextFiles

@JdeBP

Of course, I should test for as many edge cases as possible.

Here are the tests, any specific ideas to improve are welcome!
https://github.com/ha1tch/slice/tree/main/tests

slice/tests at main · ha1tch/slice

A small command-line utility to extract a byte slice from any position in a file and optionally trim truncated lines. - ha1tch/slice

GitHub