0

I have a series of commands running through a pipeline like this:

cmd1 | cmd2 | cmd3 | cmd4

How can I print the intermediate result of cmd1, cmd2 and cmd3? I know I can use the tee command to print the result to a file. But is it possible to just print it to the console? This is for debugging purpose as my actual commands are very complex.

1 Answer 1

3

You can tee to the current terminal:

cmd1 | tee /dev/tty | cmd2 | tee /dev/tty | cmd3 | tee /dev/tty | cmd4
4
  • Thank you! This works. Do you know is it possible to let tee's print result on its own line? May 14, 2020 at 9:49
  • I’m not sure I understand the question. Do you want to be able to distinguish the output from multiple tees, or distinguish the teed output from cmd4’s output? May 14, 2020 at 9:55
  • I want to be able to distinguish the output from multiple tees. May 14, 2020 at 9:56
  • 1
    I think that should be possible by redirecting tee’s extra output to new file descriptors, and then decorating those outputs with ts or something similar, but my shell-fu in that area is weak. May 14, 2020 at 16:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .