DEV Community

Kyota Nakada
Kyota Nakada

Posted on

xcut: A Flexible CLI Tool for Extracting and Filtering Text Columns

If you've ever used the Unix cut command but wished it could do more—like filtering rows by content, handling CSV headers, or using regular expressions—then xcut might be what you're looking for.

xcut is a command-line tool written in Rust that extends the capabilities of cut, awk, and grep. It's ideal for processing logs, tabular data, or structured plain-text files with customizable delimiters and filters.

Image description

🔧 Features

  • Column-based extraction (--cols)
  • Regex & boolean filtering (--filter)
  • Custom delimiters (--delim, --max-split)
  • Output formatting (--out-delim, --output)
  • Header skipping (--no-header)
  • head and tail-like line selection

📦 Installation

Using Homebrew (macOS/Linux):

brew tap kyotalab/xcut
brew install xcut
Enter fullscreen mode Exit fullscreen mode

Using GitHub Releases:

curl -LO https://github.com/kyotalab/xcut/releases/latest/download/xcut
chmod +x xcut
./xcut --help
Enter fullscreen mode Exit fullscreen mode

🚀 Examples

Extract specific columns

xcut --input logs.txt --cols 1,3
Enter fullscreen mode Exit fullscreen mode

Filter rows using regex (e.g., lines where col 3 starts with "INFO")

xcut --input logs.txt --filter 'col(3) =~ "^INFO"' --cols 3,4
Enter fullscreen mode Exit fullscreen mode

Handle CSV with headers

xcut --input data.csv --delim ',' --cols 1,2 --no-header
Enter fullscreen mode Exit fullscreen mode

Output to a file and format with a delimiter

xcut --input data.txt --cols 1,3 --out-delim ',' --output result.csv
Enter fullscreen mode Exit fullscreen mode

💡 Why Use xcut?

Unlike traditional tools, xcut gives you:

  • Regex filtering in-line
  • Logical expressions for filtering
  • Cleaner syntax for column extraction
  • Cross-platform behavior with a single binary

📚 Learn More

Give it a ⭐️ on GitHub if you find it useful!


Feel free to share your feedback or contribute to the project 🙌

Top comments (0)