You are not logged in.
I was wanting to view the output of commands as a text file, and was wondering if there was a way to achieve this. I know you can redirect the output to text, but I was wondering if there is any way to put it there after the command is run as opposed to redirecting it while it is run. So far my searches aren't looking good and I'm leaning towards thinking that it isn't possible and I should just redirect the output before hand, but I wanted to see if there was a way I missed. Does anyone know of any?
Last edited by jgreen1tc (2013-05-10 12:50:39)
Offline
I'm not sure I really understand. You want to run a command, then *after the fact* put its output into a text file? Unless you have a spare flux capacitor laying around, I don't see how this would make any sense: how would your computer know which output to put into a text file? Again, I think I must be misunderstanding, perhaps you could give an example of how this could be used to clarify.
Also, if you can compare/contrast to `tee` that would help. Or perhaps tee is just what you need - it "duplicates" output and sends one copy to stdout as usual and one copy to a file.
EDIT: I suppose you could also get really creative (depending on your terminal and environment) with things like xdotool, xsel, and others to "copy and paste" everything between the last prompt and the previous prompt.
EDIT2: this has a really cool result "bash | tee mylogfile". This gives you a normal bash session, but "logs" all the output in logfile. You could then do some wizardry with grep, or awk to get only the ouput from the last command from that logfile. And this does seem to work in "real time". I can see the output of the last command in the log file from within the bash session that is being logged. This does not log your PS1 which would be useful for extracting the last output only, but it does log anything that is echoed from PROMPT_COMMAND. So you could put some sort of delineating marking in PROMPT_COMMAND, then run a logged session, and show the contents of the log only between the last two markers.
Last edited by Trilby (2013-05-09 14:40:52)
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
Copy/Paste is the only way I know of.
Offline
You could use the 'script' command which makes a typescript of a terminal session. The resulting file would contain your commands as well as the output. See 'man script' for more details.
Offline
There is a hardcopy command for GNU Screen, and it can do what you want, but not automatically.
Offline
You could use the 'script' command which makes a typescript of a terminal session. The resulting file would contain your commands as well as the output. See 'man script' for more details.
This command is pretty much exactly what I was looking for. Thanks.
Offline
Don't forget [SOLVED].
Offline