| Crates.io | xcut |
| lib.rs | xcut |
| version | 0.1.0 |
| created_at | 2025-06-03 04:05:39.373006+00 |
| updated_at | 2025-06-03 04:05:39.373006+00 |
| description | An extended cut command with regex filtering and formatting |
| homepage | https://github.com/kyotalab/xcut |
| repository | https://github.com/kyotalab/xcut |
| max_upload_size | |
| id | 1698637 |
| size | 29,135 |
xcut is an extended version of the Unix cut command, with support for filtering, column extraction, and flexible delimiters.
It is written in Rust and supports cross-platform usage (Linux, macOS, Windows via CMD or Git Bash).
--cols)--delim, --max-split)--filter)--out-delim, --output)--no-header)--head, --tail)xcut [OPTIONS]
-i, --input <INPUT>
Path to the input file. Reads from stdin if not specified
-f, --filter <FILTER>
Filter expression to match lines. Supports regex and boolean logic.
Examples:
col(3) == "INFO"col(4) =~ "^CPU"col(3) !~ "DEBUG" && col(4) =~ "error"-c, --cols <COLS>
List of column numbers to output (1-based index).
Example: --cols 1,3
--delim <DELIM>
Delimiter used to split each line into columns. Default is whitespace
--max-split <N>
Maximum number of splits to perform when using --delim. Useful to preserve trailing content in the last field
--out-delim <OUT_DELIM>
Delimiter used to join output fields. Default is a space
-o, --output <OUTPUT>
Path to output file. Appends to the file if it exists. Defaults to stdout
--no-header
Skip the first line (e.g. header in CSV files)
--head <HEAD>
Output only the first N lines (like head)
--tail <TAIL>
Output only the last N lines (like tail)
-h, --help
Print help (see a summary with -h)
-V, --version
Print version
You can filter lines using column values. Examples:
| Expression | Description |
|---|---|
col(2) == "INFO" |
Select rows where column 2 equals "INFO" |
col(2) != "INFO" |
Select rows where column 2 is not "INFO" |
col(4) =~ "CPU" |
Regex match: column 4 contains "CPU" |
col(3) !~ "DEBUG" |
Regex not match |
col(2) == "INFO" && col(4) =~ "CPU" |
Logical AND of two conditions |
| `col(2) == "INFO" |
## Extract columns 2 and 4 with space as delimiter, max 4 splits
xcut --input sample_logs.txt --cols 2,4 --delim ' ' --max-split 4
# Filter lines where column 3 matches regex and output to a file
xcut --input sample_logs.txt --filter 'col(3) =~ "ERROR"' --output errors.txt
# Only take the first 10 lines, skip the header
xcut --input data.csv --no-header --head 10 --cols 1,2,3 --delim ','
# Use regex negation
xcut --input logs.txt --filter 'col(3) !~ "DEBUG"'
PowerShell has issues interpreting !~, quotes, and parentheses.
For best results on Windows:
To run integration tests, make sure the binary is built first:
cargo build
cargo test
The tests expect target/debug/xcut to be available. If you want to run tests directly without building separately, simply use:
cargo test