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

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

 



On Fri, 2004-01-23 at 17:46, Herculano de Lima Einloft Neto wrote:
> Mike Klinke wrote:
> > saveit find ....
> > saveit grep ....
> 
> Then I would have to type saveit everytime.. thanks for all your
> effort, but I'll be more exact as to what I really want: use bash
> just the way I always have, and when the _unexpected_ wish to
> manipulate the last output gets me by surprise, I will do, for instance:
> (say, with grep)
> 
> grep whatever $__
> 
> There.. wouldn't it be nice? :)

Okay - this has some problems, but if you really want this, you could
work around them.

Just roll your own output capture.

while read line
do 
  bash -c "$line" | tee /tmp/last.out1
  mv /tmp/last.out1 /tmp/last.out
done

This gives you the output of your last command in a fixed file
(/tmp/last.out). You can point a shell variable at that file if you
prefer the $_ notation - just need to make sure it is set at every pass
through the while loop. 

On the downside, you loose command history, search etc. etc.

It may be that a combination of using exec's redirection and a fifo may
make this cleaner - an interesting exercise :)

Cheers, Ben

-- 
.O.    Ben Stringer
..O    ben@xxxxxxxxxxx
OOO    linux|java|majitek|gnu




[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux