ptee(1)

πŸ’– ptee β€” the manual page, but make it a group chat πŸ’–

okay so bestie, you found the ptee(1) page. it's a User Commands girlie, and she's literally the piped version of tee(1). let's get into it 🫢


✨ NAME ✨

ptee β€” piped tee: read from one file descriptor and copy to many 🌈


πŸŽ€ SYNOPSIS πŸŽ€

ptee [-h] [-r infd] outfd1 [outfd2 ...]

that's the whole vibe. one input, a whole squad of outputs. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea: ptee reads from one file descriptor β€” that's 0 / stdin by default, no cap β€” and then copies literally everything it reads to all the output file descriptors you hand it. all of them. every single one. it's giving "one message, many group chats." πŸ‘‘

she's a piped version of tee(1), which is the whole point. tee(1) is great but she's out here working with files and pipes in a specific way, and ptee is the version that just speaks file descriptor. iykyk.

and here's the iconic part: you can use ptee together with pipexec(1) to fit the output of one command into many other commands. one command's output, fanned out to a bunch of other commands. no middleman. no temp files. we love a direct line. πŸ’–


πŸ’… OPTIONS πŸ’…

  • -h β€” prints help and version information. the "hey bestie, what are you" flag. πŸŽ€
  • -r infd β€” use the given infd as the input file descriptor. if you don't specify this one, 0 (stdin) gets used by default. simple as that. ✨

πŸ”₯ EXAMPLES πŸ”₯

duplicating to a whole crew

want to duplicate all data from stdin to stdout, stderr and fd 7? say less:

ptee 1 2 7

the tee equivalent moment

the command

tee output.txt

is equivalent to the shell command

ptee 5 5>output.txt

same energy, different fit. πŸ‘‘

the pipexec(1) collab 🀝

okay this one is the main character. using pipexec(1): count all files in the file system and additionally count only those that have a uppercase 'A' in their name. and listen β€” the file system will be scanned only once. no temporary files are generated. not a single one. efficiency queen. πŸ’œ

pipexec [ LS /bin/ls -R / ] [ PTEE /usr/bin/ptee 3 4 ] \
  [ WC1 /usr/bin/wc -l ] [ GREP /bin/grep A ] \
  [ WC2 /usr/bin/wc -l ] "{LS:1>PTEE:0}" "{PTEE:3>WC1:0}" \
  "{PTEE:4>GREP:0}" "{GREP:1>WC2:0}"

look at that wiring. LS into PTEE, PTEE out to WC1 and GREP, GREP into WC2. gorgeous. no notes. 🌸


🌟 SEE ALSO 🌟

pipexec(1), peet(1), tee(1) β€” go read the family, they're all icons. 🧚


πŸ‘‘ AUTHOR πŸ‘‘

Written by Andreas Florath (andreas@florath.net). legend behavior, honestly. πŸ’–


Copyright Β© 2015 by Andreas Florath (andreas@florath.net). License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.


real talk: this page came from the User Commands section, dated 2015-03-14, and that's the whole thing bestie β€” ptee(1), read once, copy everywhere, no temp files, periodt. πŸ’…βœ¨πŸ¦‹