Skip to content

jswrenn/turnout-for-what

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 

turnout-for-what

https://upload.wikimedia.org/wikipedia/commons/a/a2/V%C3%BDm%C4%9Bna_hrotit%C3%A1.jpg

Usage

tfw SWITCH
SWITCH
A file descriptor yielding a stream of line-separated paths. For every line received from stdin, the last path received from SWITCH indicates the file that the line should be redirected to.

Example

A load-balancer for the natural numbers:

#!/usr/bin/env bash

trap "rm -f nat {0..4}; pkill -P $$" EXIT

touch nat {0..4}

while true; do
  echo $((i++))
  sleep 0.2;
done > nat &

tail -f nat | cargo run -- <(tail -f nat | xargs -I{} expr {} % 5) &

while true; do
  sleep 0.2
  clear
  wc -l {0..4}
done

This script will create five text files, balance the natural numbers between them, and continuously print their line counts.

About

Shell utility for conditional redirection.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages