Ubuntu: How to open a new terminal, execute a process in that terminal and pipe to the process?


What I'd like to do basically is a new-window version of less. Long ago there was a tool called gless which did exactly that. For example

cat my_very_long_file | gless  

would open a new window and run a less-like pager showing my very long file; the terminal from which I launch the command would stay clean.

gless is not available in newer systems. The closest alternative I found is gview - (practically gvim in read-only mode, reading standard input) but this isn't the exact thing; it reads in the whole stdin before displaying anything, so isn't good for large inputs.

I thought of running a new terminal (xterm, konsole or anything) with less as the initial command. But it doesn't work the way I want; I would like to do something like

cat my_very_long_file | xterm -e less  

But xterm and all other terminals don't seem to pass their standard input to the process they run - the new window opens, but disappears immediately.

(I know I can start the command in the new terminal; but it's not what I want. I really want to run a command in the current shell and redirect to a new process. cat is just an example.)

As a test of any suggested method, please consider this as a test case:

od -a /dev/random | <whatever-solution>  

With the solution substituted, this should create a new window with a pager (or any other program for that matter) that receives an endless random stream of text.

(Late addition) I am looking for a simple solution that will keep the spirit of piping to a pager. Multi-step solutions can work but are unnatural. There is a single command line that also works: xterm -e 'whatever | less', I use it sometimes but it is unnatural for me.


How about a named pipe?

mkfifo /tmp/test.fifo  od -a /dev/urandom > /tmp/test.fifo  

And in the new window:

cat /tmp/test.fifo | less  


gnome-terminal -e "bash -c 'cat /tmp/test.fifo | less'"  


Try adding this funcation to your ~/.bashrc:

gless() { gnome-terminal -e "less $*" & }  

This starts the terminal in the background, freeing your console. Also it passes all arguments to the less command (e.g. gless -S test.txt)

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »