Is the output of a Bash command stored in any register? E.g. something similar to $?
capturing the output instead of the exit status.
I could assign the
One that I've used for years.
.bashrc
or .bash_profile
)# capture the output of a command so it can be retrieved with ret
cap () { tee /tmp/capture.out}
# return the output of the most recent command that was captured by cap
ret () { cat /tmp/capture.out }
$ find . -name 'filename' | cap
/path/to/filename
$ ret
/path/to/filename
I tend to add | cap
to the end of all of my commands. This way when I find I want to do text processing on the output of a slow running command I can always retrieve it with res
.