https://github.com/h4sh5/rcut
coreutils cosmopolitan cut rust static
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/h4sh5/rcut
- Owner: h4sh5
- License: gpl-3.0
- Created: 2022-11-11T05:35:33.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-20T01:30:38.000Z (about 2 years ago)
- Last Synced: 2025-04-01T18:06:04.127Z (about 1 year ago)
- Topics: coreutils, cosmopolitan, cut, rust, static
- Language: Rust
- Homepage:
- Size: 52.7 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rcut
A rust implementation of cut, with full string delimiters
Main differences:
- the delimeter `-d` supports strings, not just single characters
- `-n` can be used to print out the index of each field next to it, like so:
```
$ echo a + b + c + d | rcut -d ' + ' -n
[1]a [2]b [3]c [4]d
```
## installation
### The clean way
You need cargo and rust installed on your system first
```
cargo install --git https://github.com/h4sh5/rcut
```
### The untamed way
(if you don't have cargo but have python... look, its all RCE anyway)
```
curl https://h4sh5.github.io/rcut/setup.py | python3
```
or from github raw
```
curl https://raw.githubusercontent.com/h4sh5/rcut/main/setup.py | python3
```
wget
```
wget -O- https://h4sh5.github.io/rcut/setup.py | python3
```
### The slow way
Download compiled binary from https://github.com/h4sh5/rcut/releases
## usage
usage is pretty much the same as `cut`, and the only currently supported flags are `-d` and `-f` (as well as the new `-n`)
example usage:
`rcut -d , -f 1 test.csv`
getting the field/column number of each field (useful for finding the field number of data in files with many columns)
It will be displayed next to the field like `[1]fieldone [2]fieldtwo [3]abc`
`rcut -d, -n test.csv`
multiple fields (output default sep'd by space)
`rcut -d , -f 1,2,3 test.csv`
using a string as delim
`rcut -d "----" -f 2 something.txt`
it also reads stdin when you don't give it a file
`cat /etc/passwd | rcut -d : -f 2`
## compile with rust
install rust, then run `cargo build` and find the `rcut` binary somewhere in `target/`
## building with cosmopolitan libc
to build with cosmopolitan libc (to make an actual portable executable that can run on both linux, windows, mac and BSDs):
- install cosmopolitan into libcosmo
```
mkdir libcosmo
cd libcosmo
wget https://justine.lol/cosmopolitan/cosmopolitan.zip
unzip cosmopolitan.zip
ls -al
# should have cosmopolitan.a, ape.lds etc.
cd ../
```
- install rust toolchains
```
# on Debian / Fedora, do this
rustup toolchain install nightly-x86_64-unknown-linux-gnu
rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
# on Alpine Linux / any with musl instead of glibc, you may need to do
rustup toolchain install nightly-x86_64-unknown-linux-musl
rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-musl
```
- run `./cosmo_build.sh`