github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

kriskowal / xbin

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 6
    • 1
  • Source
  • Commits
  • Network (1)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

~/bin — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Added findall 
paulbaumgart (author)
Sun Jan 03 23:03:52 -0800 2010
commit  32514b45ec0661a01da18d9ba157ebf7ab5c1719
tree    eef11b5ee5c9ce38ba86975cc08ee1e20951e80b
parent  2614bd0945aa03bebe99f4d71b2f210ed6bc5836
xbin /
name age
history
message
file README.md Sun Jan 03 23:04:32 -0800 2010 Added findall [Paul Baumgart]
directory bin/ Sun Jan 03 23:04:32 -0800 2010 Added findall [Paul Baumgart]
file package.json Sat Aug 08 15:28:38 -0700 2009 Added package.json and relinewrapped README [kriskowal]
README.md

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>"

TODO

sample

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.

Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server