sel — Select Slices from Text Files
0.2.0 — compact CLI (and Rust library) for extracting fragments from
text by line numbers, ranges, positions (line:column), or regex. Streams
input so it scales to large files; supports stdin, file output, and colored
output with context.
Documentation
| Resource | Description |
|---|---|
| docs/README.md | Index of all project docs |
| docs/USAGE.md | Full CLI reference |
| docs/ARCHITECTURE.md | Pipeline and module design |
| CONTRIBUTING.md | Build, test, PR workflow |
| CODE_OF_CONDUCT.md | Community Code of Conduct |
| CHANGELOG.md | Release notes |
| docs.rs/sel-rs | Rust API reference |
Features
- Line selectors: single (
42), ranges (10-20), lists (1,5,10-15,22). - Positional selectors:
line:columnwith per-character context. - Regex search (
-e PATTERN) with optional invert (-v). - Line context (
-c N): N lines around each match, windows merged on overlap. - Streaming: single-pass
BufReaderpipeline; memory independent of file size. - Stdin: no file arg or
-reads stdin (positional selectors need a seekable file). - Output to file (
-o PATH), never clobbers unless--force. - Color (
--color auto|always|never) with ANSI highlighting.
Installation
# From crates.io (the crate is published as `sel-rs`; the binary is still `sel`)
# From source
&&
Pre-built binaries for Linux, macOS, and Windows are published on the
Releases page via
cargo-dist.
Claude Code skill (optional)
Teach Claude Code to prefer sel over sed -n '…p' for line extraction:
# User-level
|
# Project-level (installs into ./.claude/skills/)
|
See contrib/claude-skill/ for details and
uninstall instructions.
Quick examples
# Lines 30–35
# A mix of singles and ranges
# Line 42 with 3 lines of context on each side
# Position (line 23, column 260) with 10 chars of context
# Regex search with context
# Invert-match: lines that do NOT match
# Multiple files (filename prefix auto-enabled)
# Stdin
|
# Write to a file, refuse to overwrite
# Whole file with line numbers (like `cat -n`)
Usage (summary)
Run sel --help for the full option list. A detailed reference lives in
docs/USAGE.md.
sel [OPTIONS] [SELECTOR_OR_FILE]...
sel [OPTIONS] -e <PATTERN> [FILE]...
Options:
-c, --context <N> Lines of context before/after matches
-n, --char-context <N> Character context (positions / regex)
-l, --no-line-numbers Suppress line numbers
-e, --regex <PATTERN> Regular expression pattern
-v, --invert-match With -e: emit non-matching lines
-H, --with-filename Always print filename prefix
--color <WHEN> auto | always | never (default: auto)
-o, --output <FILE> Write output to FILE (`-` = stdout)
--force With -o, overwrite an existing file
-h, --help Print help
-V, --version Print version
Development
Requires Rust 1.92+ (edition 2024), as set in Cargo.toml.
Contributions welcome — see CONTRIBUTING.md and CODE_OF_CONDUCT.md.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual-licensed as above, without any additional terms or conditions.
Author
Pavel Obruchnikov a.k.a InkyQuill — https://github.com/InkyQuill