In Mathematica, it is possible to reuse the output of the previous command by using %.
Is something similar possible for bash (or some other shell)?
For example, I run a make which gives warnings, but I want to find all warnings.
So, I type
make | grep "warning"
but I’m not able to see the output of the make then.
I would like to type something like this instead:
make
% | grep "warning"
Since the amount of output is indeterminate, it doesn’t make sense for
bashto store it for you for re-display. But there’s an alternate solution to your problem:The
teecommand allows you to duplicate an output stream to a file. So if you’re willing to use a file for temporary storage, you can do something like this:This solution avoids running
maketwice, which could be (a) expensive and (b) inconsistent: the second make may be doing less work than the first because some targets were already made the first time around.Note: I haven’t tried this. You may need to fiddle with joining the error and output streams, or such.