parts - Reads text input to split parts by given separator and prints the chosen range.
Usage:
parts [OPTIONS] RANGE
Options:
-f | --file FILENAME | Use FILENAME as input.
-s | --split SEPARATOR | Split input by SEPARATOR. (defaults to %C)
-n | --num | Show number of parts available for given options.
--help | Show this help.
--license | Print license.
--version | Print version.
Separator:
Any string you want. (see examples below)
Predefined:
%C | Character
%E | Empty line
%N | Newline
%S | Space/Fields
Range:
Index starts at 0 until max occurrence.
Usage:
0 | First part.
1 | Second part.
2:4 | Third and forth parts.
:4 | Get all from beginning until the forth part.
3: | Forth part until the end
3:-1 | Forth part until second to last.
Examples:
echo "ABC" | parts 1: | Split by character, returning the range from second until the last character.
BC
echo "ABC" | parts -s "B" 1 | Split by string "B", returning the second (1) part.
C
cat /proc/loadavg | parts -s %S 0:3 | Split by spaces (%S), returning all 3 load averages.
0.11 0.09 0.14
parts -s %E -f LICENSE -3 | Split by empty lines (%E), returning the second clause of the BSD-3-Clause file.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.