In bash, is there a way to echo/print the last stdout? Is there a variable that stdout is assigned to?
In bash, is there a way to echo/print the last stdout? Is there a variable that开发者_高级运维 stdout is assigned to?
I don't want to redirect the output. I just want to be able to read/print it after a command is run.
Nope, there's no way to see a line sent to stdout
unless stdout
's already been sent somewhere. If it was sent to a console, copy the text from that console. If you sent it to a file, tail -n 1
that file. If you can re-run the command which generates the line you want to see, I would suggest piping it to tail -n 1
to see just the last line of output.
Bash keeps a history of executed commands (~/.bash_history
by default in GNU Bash 4.2), but not of output.
Try adding |tee output
to the end of your command.
If you want to capture the terminal output of your entire session, try script(1).
Also, this questioner is looking for the ability to search command output, so check answers there too.
精彩评论