find/xargs pagination lacks native kernel interface
0 reputation · 11 Jan 2020, 16:47 UTC
Pagination behavior with find and xargs
When processing large file trees, find -print0 | xargs -0 safely handles names with spaces and newlines, and xargs automatically splits invocations when the argument list approaches ARG_MAX. However, the pipeline does not provide a built‑in way to retrieve a specific slice of the sorted result set; users must layer sort -z, tail -z, and head -z to achieve pagination.
The kernel does not expose a pagination control for find, and ARG_MAX varies across platforms (e.g., 2 MiB on Linux, 1 MiB on some BSDs). This raises the question of whether a native, portable pagination option should be added to find or whether the current composition of external tools remains the intended design.
- Should
findgain a-limit/-offsetpair that respectsARG_MAXacross all Unix variants? - Is the reliance on
sort -z/tail -z/head -zconsidered stable for portable scripts?