| Crates.io | sbcut |
| lib.rs | sbcut |
| version | 1.0.1 |
| created_at | 2025-12-24 21:36:15.419379+00 |
| updated_at | 2025-12-24 21:36:15.419379+00 |
| description | A slightly better implementation of the cut command in Linux with Python-style indexing |
| homepage | |
| repository | https://github.com/lyubolp/slightly-better-cut |
| max_upload_size | |
| id | 2003884 |
| size | 156,119 |
A slightly better implementation of the cut command in Linux with Python-style indexing.
TBD
TBD
git clone https://github.com/lyubolp/slightly-better-cutcargo build -r<repo_dir>/target/release/sbcutUsage: sbcut [OPTIONS] <--bytes <LIST>|--characters <LIST>|--fields <LIST>> [FILE]
Arguments:
[FILE] [default: -]
Options:
-b, --bytes <LIST>
-c, --characters <LIST>
-d, --delimiter <DELIM> [default: "\t"]
-f, --fields <LIST>
--complement
-s, --only_delimited
--always_show_no_delimited_lines
--output_delimiter <DELIM>
-z, --zero_terminated
-h, --help Print help
-V, --version Print version
Print selected parts of lines from each file to standard output.
With no FILE or when FILE is - , read from standard input.
Options:
-b, --bytes=LIST - select only those bytes-c, --characters=LIST - select only these characters-d, --delimiter=DELIM - use DELIM instead of TAB for field delimiter-f, --fields=LIST - select only these fields; also print any line that contains no delimited character, unless the -s option is specified--complement - complement the set of selected bytes, characters or fields-s, --only-delimited - do not print lines not containing delimiters--output-delimiter=STRING - use STRING as the output delimiter the default is to use the input delimiter-z, --zero-terminated - line delimiter is NUL, not newline--help display this help and exit--version - output version information and exitUse one, and only one of -b, -c or -f. Each LIST is made up of one range, or many ranges separated by commas. Selected input is written in the same order that it is read, and is written exactly once. Each range is one of:
N:M:S - N is start, M is end, S is step.
Defaults - N = 1, M = last character of current line, S = 1. N < M !
Return all bytes, characters or fields in the range, defined by N, M and S
Given the following file:
ID,Name,Age,Email,City,Country,Occupation,Salary
1,John Doe,28,john.doe@example.com,New York,USA,Software Engineer,80000
2,Jane Smith,34,jane.smith@example.com,Los Angeles,USA,Data Analyst,75000
3,Bob Johnson,45,bob.johnson@example.com,Chicago,USA,Project Manager,90000
We can extract only the first column:
(Fields are zero-indexed)
$ sbcut -d "," -f0 sample_bigger.csv
ID
1
2
3
The last two:
$ sbcut -d "," -f-2: sample_bigger.csv
Occupation,Salary
Software Engineer,80000
Data Analyst,75000
Project Manager,90000
First column, third to fith and last two:
$ sbcut -d "," -f0,2:4,-2: sample_bigger.csv
ID,Age,Email,Occupation,Salary
1,28,john.doe@example.com,Software Engineer,80000
2,34,jane.smith@example.com,Data Analyst,75000
3,45,bob.johnson@example.com,Project Manager,90000
Every even-numbered column:
$ $sbcut -d "," -f::2 sample_bigger.csv
ID,Age,City,Occupation
1,28,New York,Software Engineer
2,34,Los Angeles,Data Analyst
3,45,Chicago,Project Manager
TBD
always_show_no_delimited_lines-z line endingTBD