If both terminals belong to the same user, you can send your output to the virtual device that is used as the particular terminal's tty.
So you can use the output from w
, which includes the TTY information, and write directly to that device.
ls > /dev/pts/7
(If the device mentioned by w
was pts/7)
Another option is to use the number of a process that is connected to that device. Send your output to /proc/<process number>/fd/1
.
ls > /proc/5555/fd/1
Assuming the process number that you found that runs in that terminal is 5555.
Note that this direct write is only allowed if the user that attempts to write is the same user that owns the other terminal.
ls
and want its output to be displayed on second terminal (with or without using any command on second) – Alex Jones Feb 11 '16 at 14:55