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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Nope, there’s no way to see a line sent to
stdoutunlessstdout‘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 1that file. If you can re-run the command which generates the line you want to see, I would suggest piping it totail -n 1to see just the last line of output.Bash keeps a history of executed commands (
~/.bash_historyby default in GNU Bash 4.2), but not of output.