Git Product home page Git Product logo

xbin's Introduction

xbin

A suite of Unix command line tools for englightened pipelines.

xip

The name "zip" was already taken. This interlaces the contents of a variadic list of files, especially handy with subshell file descriptor replacement. The following shows the opposing sides of a six sided die. The first example works in BSD variants, and the second in SysV/Linux variants::

xip <(jot 6) <(jot 6 6 1) | xargs -n 2
xip <(seq 6) <(seq 6 -1 1) | xargs -n 2

dog

Buffers stdin into memory until it closes, then writes to a given file. This is handy for pipeline loops, where normally redirecting to and from the same file would result in premature truncation. The following are equivalent::

sort file
cat file | sort | dog file

shuffle

Shuffles the lines from standard input and writes them to standard output. If the input stream is indefinite, the input can be shuffled indefinitely by specifying a pool size as a second argument.

enquote

Enquotes every line from standard input and writes it to standard output. Handy for pipelines that end in xargs, when file -print0 and xargs -0 aren't really an option. The following are pretty close to equivalent:

find . -print0 | xargs -0 tar cf -
find . | enquote | xargs tar cf -

cycle

Reads all of standard input and writes it back, repeatedly, to standard output. The first pass gets written immediately, so an indifinite stream will only cause memory bloat at the rate at which cycle's standard output is consumed::

find . -name '*.mp3' \
| cycle \
| shuffle 10000 \
| enquote \
| xargs -n 1 mpg123

findall

Convenience command for find . -name "<file_pattern>" -print0 | xargs -0 grep "<grep_pattern>". Significantly faster than grep -r.

findall "<pattern1>"

is equivalent to

find . -name "*" -print0 | xargs -0 grep "<pattern1>"

while

findall "<pattern1>" "<pattern2>"

expands to

find . -name "<pattern1>" -print0 | xargs -0 grep "<pattern2>"

samp

Writes a random sample of the lines from standard input back out to standard output. Specify a sample size as an argument. The sample is in stable order. The input stream may safely be of indefinite size.

This program is called samp so as not to collide with bsd's random or OS X's sample.

unique

Reads lines from standard input and writes the first of each unique line. This is similar to the behavior of the highly optimized uniq. uniq suppresses the output of sequentially redundant lines, so to create a truly unique set, the common idiom is to sort the input. However, this does not preserve the order. In this sense, unique is a "stable" operation.

The following are equivalent:

cat input | sort | uniq | dog output
cat input | unique | sort | dog output

Example, removing redundant elements from $PATH:

export PATH=$(
    echo $PATH \
    | tr ':' '\n' \
    | unique \
    | paste -sd: -
)

activate

Source this script to add this project to your PATH.

. bin/activate

mkroot

After activating this project, use mkroot to replicate it.

mkroot foo

See https://github.com/kriskowal/mkroot for details.

xbin's People

Contributors

kriskowal avatar paulbaumgart avatar ryanwitt avatar

Stargazers

Kumarajiva avatar Angus H. avatar Ximing avatar Stuart Knightley avatar Steve Larkin avatar Michael H. avatar  avatar André Berg avatar  avatar  avatar Rock Howard avatar C Dorn avatar Alfred Westerveld avatar Aria Stewart avatar Leonard avatar

Watchers

 avatar  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.