I know you can use the last argument passed to last the last command by hitting Alt-.. Is there a similar binding to get the output of the last command, or in other words the last value printed to stdout?

These questions are closely related but are not focused an a binding:
bash: get last stdout
How do I reuse the last output from the command line?

  • 1
    As unix.stackexchange.com/questions/9024/… explains, there's no way to do that. What do you want a binding for? For running the last command again and capturing its output (which may be different this time)? Sep 22, 2021 at 15:11
  • No, there isn't. Can you explain what exactly you want to achieve? Someone's likely to have come up with a workaround :-) Sep 22, 2021 at 15:22

1 Answer 1


No, because while the shell is involved in setting up the input/output file descriptors of the programs it runs based on any redirections, it's not involved in the actual data that passes between the running process and the terminal or files or such.

You'd need to explicitly arrange some way of capturing the output of all commands in advance to be able to access it again. Or run the command again, if the output of a second invocation would be useful.

There are some hacks to doing that in How do I reuse the last output from the command line?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.