1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 19:47:45 +00:00

split: implement outputting kth chunk of file

Implement `-n l/k/N` option, where the `k`th chunk of the input file
is written to stdout. For example,

    $ seq -w 0 99 > f; split -n l/3/10 f
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
This commit is contained in:
Jeffrey Finkelstein 2022-01-05 21:06:04 -05:00 committed by Sylvestre Ledru
parent bb379b5384
commit ee36dea1a9
3 changed files with 180 additions and 0 deletions

View file

@ -587,3 +587,11 @@ fn test_lines() {
assert_eq!(file_read("xaa"), "1\n2\n3\n");
assert_eq!(file_read("xab"), "4\n5\n");
}
#[test]
fn test_lines_kth() {
new_ucmd!()
.args(&["-n", "l/3/10", "onehundredlines.txt"])
.succeeds()
.stdout_only("20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n");
}