[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: bash: any way to reuse the last output?



On Jan 23, 2004, Herculano de Lima Einloft Neto <hlen ig com br> wrote:

>     This happens all the time: after an intricate find, I decide
> to grep something out of that very same find, for instance. It
> would be nice to have some tweak to reuse the last output without
> having to run the command again. Anyone?

Such output is not really saved anywhere.  Were the shell to actually
save it, it would have to intercept stdout (and stderr?) of the
application it runs and record the outputs somewhere it could replay
them.  Should you want to distinguish stdout from stderr, the shell
would have to maintain two such buffers, and synchronization of their
outputs would no longer be possible, i.e., you could get out-of-order
output on your screen depending on how the shell interceptors happened
to be scheduled.  Not a good idea.

Not to mention that it would make the shell significantly less
efficient: consider a program whose output is huge.  You surely don't
want this to be kept in memory (or even on disk) if it's not to be
used afterwards.  Just collecting all this output would waste a lot of
CPU.  There's this rule about optimizing for the common case.  Common
case is to output to the output terminal and be done with it.

If you need its output, just run it again.

Now, if you really want to be able to take the output of some random
program you ran and feed that into another program, there are ways
to do that.  Start GNU screen, or a shell within GNU Emacs, or just
use some terminal program with a configurable scrollback buffer and,
whenever you need the output of some other program, you can scroll
back and cut&paste the output into the input of another program.  No
need to build such abilities into the shell.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Happy GNU Year!                     oliva {lsd ic unicamp br, gnu.org}
Red Hat GCC Developer                 aoliva {redhat com, gcc.gnu.org}
Free Software Evangelist                Professional serial bug killer




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]