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

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

 



Herculano de Lima Einloft Neto wrote:

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? :)

Nope. Think of the command which produces a really long output...do you want it to be saved in memory?


Anyway, there are a several solutions to your problem. First, as it was mentioned here already, you can use tee or output redirection (> or >>). Second, you can use script command (see 'man script' for details). Third, you can save command output into a variable, like this:

OUT=`find /`

and use it like any other shell variable.
(Fourth;) You can even make a short script, like this:

#!/bin/bash
# so - Save Output. Saves output of command in OUT shell variable.
OUT=`$*`
echo $OUT

and use it like this
so find . -name myfile

And the last thing is to copy-paste from your terminal.




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

  Powered by Linux