Skip to content

bonzitechnology/ripcut

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ripcut

A fast Go implementation of the POSIX cut utility with enhanced multi-character delimiter support.

Features

  • Multi-character delimiters: Unlike standard cut, supports delimiters longer than one character
  • Multi-character output delimiters: Output can use any string as field separator
  • Field reordering: Output fields in any order specified on command line
  • High performance: Written in Go for speed and efficiency
  • Full POSIX compatibility: Supports all standard cut options
  • Field, character, and byte extraction: Complete feature parity with standard cut
  • Complement mode: Extract everything except specified ranges
  • Range support: Use ranges like 1-3, -5, 7- for flexible extraction

Usage

# Basic field extraction
echo "one,two,three" | ripcut -d "," -f 2
# Output: two

# Multi-character delimiter
echo "one::two::three" | ripcut -d "::" -f 1,3  
# Output: one::three

# Field reordering - output in command-line order
echo "a,b,c" | ripcut -d "," -f 3,1,2
# Output: c,a,b

# Multi-character output delimiter
echo "a,b,c" | ripcut -d "," -f 1,3 --output-delimiter=" | "
# Output: a | c

# Character ranges
echo "hello world" | ripcut -c 1-5
# Output: hello

# Byte extraction from position to end
echo "hello world" | ripcut -b 7-
# Output: world

# Complement mode (everything except specified)
echo "abcdef" | ripcut -c 2,4 --complement
# Output: acef

Command Line Options

  • -f LIST: Select fields (use with -d)
  • -c LIST: Select characters
  • -b LIST: Select bytes
  • -d DELIM: Use DELIM as field delimiter (supports multi-char)
  • --complement: Complement the selection
  • -s: Only print lines containing the delimiter
  • --output-delimiter STRING: Use STRING as output delimiter

Building

Using Makefile (Recommended)

# Build the binary
make build

# Install to /usr/local/bin 
make install

# Clean build artifacts
make clean

# Build for multiple platforms
make build-all

# Show all available targets
make help

Manual Build

go build -o ripcut main.go

Performance

This implementation is optimized for speed and can handle large files efficiently. The multi-character delimiter support is implemented without regular expressions for better performance.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors