Skip to content

Instantly share code, notes, and snippets.

@plaster
Last active December 21, 2016 17:38
Show Gist options
  • Save plaster/ef2fab0230a6916b78ca535a3e2a60ff to your computer and use it in GitHub Desktop.
Save plaster/ef2fab0230a6916b78ca535a3e2a60ff to your computer and use it in GitHub Desktop.
tee pipe
ル╹ヮ╹ルɔ jolokia:~
% (yes | tee /tmp/yes.txt | while read; do sleep 1; done) &
[1] 303
ル╹ヮ╹ルɔ jolokia:~
% while true; do sleep 1; ls -lh /tmp/yes.txt; done
-rw-r--r-- 1 plaster plaster 64K Dec 22 02:20 /tmp/yes.txt
-rw-r--r-- 1 plaster plaster 64K Dec 22 02:20 /tmp/yes.txt
-rw-r--r-- 1 plaster plaster 64K Dec 22 02:20 /tmp/yes.txt
-rw-r--r-- 1 plaster plaster 64K Dec 22 02:20 /tmp/yes.txt
-rw-r--r-- 1 plaster plaster 64K Dec 22 02:20 /tmp/yes.txt
-rw-r--r-- 1 plaster plaster 64K Dec 22 02:20 /tmp/yes.txt
-rw-r--r-- 1 plaster plaster 64K Dec 22 02:20 /tmp/yes.txt
-rw-r--r-- 1 plaster plaster 64K Dec 22 02:20 /tmp/yes.txt
^C
# thanks to @hio: https://twitter.com/hio/status/811624580364144640
ル╹ヮ╹ルɔ jolokia:~
% (yes | strace -e write -o /tmp/tee-strace.log tee /tmp/yes.txt | while read; do sleep 1; done) &
[1] 738
ル╹ヮ╹ルɔ jolokia:~
% tail -f /tmp/tee-strace.log
write(3, "y\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\n"..., 8192) = 8192
write(1, "y\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\n"..., 8192) = 8192
write(3, "y\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\n"..., 8192) = 8192
write(1, "y\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\n"..., 8192) = 8192
write(3, "y\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\n"..., 8192) = 8192
write(1, "y\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\n"..., 8192) = 8192
write(3, "y\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\n"..., 8192) = 8192
write(1, "y\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\n"..., 8192) = 8192
write(3, "y\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\n"..., 8192) = 8192
write(1, "y\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\ny\n"..., 8192
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment