Write command in one terminal, see result on other one

I want to run a command foo on one terminal and pass the result to another terminal. Is it possible to do this ?

Yes, it is. A picture worth a thousand words:

radu's terminal

So, you have to redirect the output of your command using > operator to /dev/pts/#. You can find # using who or w command. If tou want to redirect and the errors, use:

<command> >& /dev/pts/#
Answered By: Radu Rădeanu

Something like this for your $HOME/.bashrc :

ng() { gnome-terminal -x sh -c "$*; bash"; }

This will run a command and shows the result on a new terminal window.


ng ls -l
ng echo foo

Edit: To consider aliases from the $HOME/.bashrc use this instead:

ng() { gnome-terminal -x bash -ic "$*; bash"; }

then the output of ls should be colored (thanks to Radu Rădeanu for this hint).

Answered By: TuKsn