Linux – Redirecting shell command outputs to another konsole shell

bashlinuxshellunix

I am writing a shell script and I would like to write commands in the script but redirect the output to other konsole sessions. (using kde)

Best Answer

First, look for the number that identifies the current tty session; lets consider the number as X:

| terminal 1               | terminal 2                |
 ------------------------------------------------------
| $ tty                    | $                         |
| /dev/pts/X               |                           |

Then, use the given number to write to the tty selected:

| terminal 1               | terminal 2                |
 ------------------------------------------------------
| $ tty                    | $ echo "foo" > /dev/pts/X |
| /dev/pts/X               |                           |

And it will produce:

| terminal 1               | terminal 2                |
 ------------------------------------------------------
| $ tty                    | $ echo "foo" > /dev/pts/X |
| /dev/pts/X               |                           |
| foo                      |                           |
Related Question