Is it possible to build a loop of commands with pipe or something else

command linepipe

So far, I know the piping mechanism as a way to connect a series of commands by connecting the stdout of one command to the stdin of the next command until the last command is reached, which connects its stdout with the display or a file.

Would it be possible, however, to make a loop out of commands, so the last command's stdout connects to the first command's stdin and maybe by using tee somehow the changing values of a certain output could be displayed?

Best Answer

Well you certainly could by just make a loop and use variables:

while true; do
    a=$(echo "$a" | grep "Hey" | cut -d" " -f2 | tee -a log)
done

That would save the last output which would be used at the beginning again

Related Question