From 3833eb6c7bd6e1fbd3854ca4962e85808c011d13 Mon Sep 17 00:00:00 2001 From: Waldir Pimenta Date: Sat, 1 Nov 2025 00:25:15 +0000 Subject: [PATCH 1/2] csplit: Clarify how the regex option works --- pages/linux/csplit.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/linux/csplit.md b/pages/linux/csplit.md index 328fc05c525f24..c51ee9d27eac6b 100644 --- a/pages/linux/csplit.md +++ b/pages/linux/csplit.md @@ -20,6 +20,6 @@ `csplit {{path/to/file}} 5 {{[-f|--prefix]}} {{prefix}}` -- Split a file at a line matching a `regex`: +- Split a file at the first line matching a `regex`: `csplit {{path/to/file}} /{{regex}}/` From 8fd47fe09d1f8e41740d743a2a06eefd5439e827 Mon Sep 17 00:00:00 2001 From: Waldir Pimenta Date: Wed, 5 Nov 2025 23:58:16 +0000 Subject: [PATCH 2/2] Clarify where csplit applies the splits --- pages/linux/csplit.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pages/linux/csplit.md b/pages/linux/csplit.md index c51ee9d27eac6b..80f17b81dc6e3c 100644 --- a/pages/linux/csplit.md +++ b/pages/linux/csplit.md @@ -4,22 +4,26 @@ > This generates files named "xx00", "xx01", and so on. > More information: . -- Split a file at lines 5 and 23: +- Split a file in two parts, starting the second one at line 10: -`csplit {{path/to/file}} 5 23` +`csplit {{path/to/file}} 10` -- Split a file every 5 lines (this will fail if the total number of lines is not divisible by 5): +- Split a file in three parts, starting the latter parts in lines 7 and 23: + +`csplit {{path/to/file}} 7 23` + +- Start a new part at every 5th line (will fail if number of lines is not divisible by 5): `csplit {{path/to/file}} 5 {*}` -- Split a file every 5 lines, ignoring exact-division error: +- Start a new part at every 5th line, ignoring exact-division error: `csplit {{[-k|--keep-files]}} {{path/to/file}} 5 {*}` -- Split a file at line 5 and use a custom prefix for the output files: +- Split a file above line 5 and use a custom prefix for the output files (default is `xx`): `csplit {{path/to/file}} 5 {{[-f|--prefix]}} {{prefix}}` -- Split a file at the first line matching a `regex`: +- Split a file above the first line matching a `regex` pattern: `csplit {{path/to/file}} /{{regex}}/`