bash: any way to reuse the last output?
Kir Kolyshkin
kir at darnet.ru
Sat Jan 24 23:12:32 UTC 2004
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.
More information about the fedora-list
mailing list