Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Possible Duplicate:
How do I reuse the last output from the command line?

If I for example type

aptitude search dia

I get a lot of unrelated stuff. At that point, I suspect that | head or | grep -w dia would have streamlined the result (had I thought of that). I could type !! | head or !! | grep -w dia but then the search is performed anew. But that's unnecessary; I'm already happy with that part. So, is there anyway to do like, most_recent_stdout | whatever.

(Note that this is just an example so I'm not looking for aptitude options or anything like that.)

share|improve this question

marked as duplicate by Mikel, Kevin, Michael Mrozek May 22 '12 at 19:29

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

add comment

1 Answer 1

To make this work, you would need to redirect stdout to a file and then cat that file. Bash doesn't save the output of commands on its own.

Alternatively, you could use a program like screen that allows you to save a transcript of your session to a file. You would get the output of everything and the command lines though.

share|improve this answer
    
If redirecting to a file could somehow be automatic, a small tool to access those files wouldn't be that difficult to write. But If you had to write > stdoutlog after each command, it wouldn't be worth the effort because you would never use it anyway. –  Emanuel Berg May 22 '12 at 18:36
2  
You could certainly implement this by hacking bash, but I would strongly advise against it. For a start, it would litter your filesystem with these files, potentially overwriting other files. Furthermore, you would have trouble redirecting output to another file. –  Lars Kotthoff May 22 '12 at 18:45
add comment

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