Consider the following example Bash one-liner in which the letters “h”, “e” and “o” are removed from the word “hello” one at a time, in that order. Only the two “l” letters remain;
$ echo "hello" | tr -d h | tr -d e | tr -d o
ll
I am trying to find a method for displaying the output of each command to the screen within the one liner, so others running it can see what is going on. Continuing with the above example I would like output as follows;
$ echo "hello" | tr -d h | tr -d e | tr -d o
hello
ello
llo
ll
Is this possible? As per the operation of the one-liner above, we are carrying the output from command to command with the vertical pipe. So I assume I would have to break from the pipe to print to stdout, which would then interrupt the “command chain” I have written. Or perhaps UPDATE: tee can be used here, but I can’t seem to achieve the desire affect.tee won’t work because it’s output is still within the boundaries of the pipe, duh!
Many thanks.
This only works on a terminal:
The
/dev/ttydevice redirects output to the current terminal, no matter where the normal output goes.