On Wed, Jul 31, 2013 at 02:09:23AM +0200, Jörn Hees wrote: > i think this would be a very useful feature and i don't seem to be alone: > http://stackoverflow.com/questions/5955577/bash-automatically-capture-output-of-last-executed-command-into-a-variable
Bash has no knowledge of, and no way to interact with, commands that it spawns. When bash runs a command (e.g. "cat file"), bash merely makes sure that stdout and the other file descriptors are properly aligned, and then calls exec(). It is the command itself (cat) which actually does the writing, and it writes directly to the terminal, or the pipeline, or wherever stdout is set to go. Bash can't "capture" this in a variable. Your TERMINAL might be able to cough up output on demand, but bash is completely unaware of the output.