Coder Social home page Coder Social logo

rcut's Introduction

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

rcut's People

Contributors

h4sh5 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.