3

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.

2 Answers 2

2

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

Or:

gnome-terminal -e "bash -c 'cat /tmp/test.fifo | less'"
1
  • Sorry, this is not what I was looking for. I want to have the convenience of a simple pipeline to a pager, much like using less. Using two or three commands to achieve that is not natural. Jun 6, 2017 at 6:49
0

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)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .