Crates.io | pipetee |
lib.rs | pipetee |
version | 1.0.1 |
source | src |
created_at | 2022-12-31 19:18:57.559243 |
updated_at | 2022-12-31 19:45:55.9469 |
description | A simple, fast, no-dependencies UNIX utility to print the contents of stdin to the terminal *and* forward them to stdout at the same time. Useful for debugging. |
homepage | |
repository | https://github.com/mark-i-m/pipetee |
max_upload_size | |
id | 748543 |
size | 7,940 |
pipetee
A simple, fast, no-dependencies UNIX utility to print the contents of stdin to the terminal and forward them to stdout at the same time.
rust 1.65+
.Via cargo:
cargo install pipetee
Via repo:
git clone github.com/mark-i-m/pipetee
cd pipetee
cargo install --path .
# output from pt will interleave with output from
# sed at the granularity of the buffer
$ yes 'yes' | pt | sed 's/yes/no/g'
no
no
no
no
no
..
no
yes
yes
yes
yes
yes
..
yes
no
no
no
no
no
..
no
^C
$ yes 'yes' | ./target/release/pt -b 3 | sed 's/yes/no/g'
yeno
s
yno
es
no
no
yesno
no
no
yes
yno
es
no
no
yesno
no
^C
# look at intermediate results if the final output takes a long time.
$ cat numbers.txt | ./computation-with-incremental-results.py | pt | sort -n | tee output.txt
# unsorted
0.0030632556724745847
0.0018044960059851569
0.001587923806107082
0.0029520906739906577
0.006344797296449427
0.1628663298523446
0.10106032701405257
0.028920997961789503
0.027188567279582024
0.02568497042514556
# after a while... sorted
0.001587923806107082
0.0018044960059851569
0.0029520906739906577
0.0030632556724745847
0.006344797296449427
0.02568497042514556
0.027188567279582024
0.028920997961789503
0.10106032701405257
0.1628663298523446
It reads from stdin and writes to both stdout and /dev/tty. Your shell will redirect stdout to whatever the next pipe is, but /dev/tty (what stdout defaults to on most shells) will remain untouched.