Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

As title. I want to copy all output that is currently in an xfce or gnome terminal session and save to a file for further analysis.

share|improve this question
    
Do you mean 'copy and paste all output in the xfce-terminal, or gnome-terminal window, and paste it into a file' or redirect it a command at a time (as John T thought) ? I'm afraid I can't advise on the use of those terminals (I use KDE) but I thought you meant copy-and-paste rather than redirect. –  pavium Dec 7 '09 at 3:46
    
By "save" I assumed he meant to a file. Could be either or I guess. –  John T Dec 7 '09 at 3:48
    
Yes, I mean copy all output on terminal, and save it to log file. –  arsane Dec 7 '09 at 3:55
    
If you know before hand that you want to save your output, start a script. –  Darren Hall Dec 7 '09 at 7:49
add comment

6 Answers 6

up vote 1 down vote accepted

Sadly I think the only really efficient/reliable solution would be to patch the pseudo-terminal code itself to do this. I've been looking for a way to do this in xfce for a while, and the cleanest answer I have at this point is: use the mouse to copy the whole buffer top to bottom, then run this:

$ xclip -selection c -o > ~/output-of-pseudo-terminal

What I really want is something that will ALWAYS log ALL my terminal output. To me, RAM and disk space are cheap, and realistically even when I accidentally hit all those stupid commands that flood the screen, a year's worth of my work on the terminal is still mere megabytes and the benefits of logging it all are many compared to how trivial it would be.

Also, while I think a patch to automatically save output is ideal, perhaps an easier workaround patch could be a command for automatically "selecting all" text and copying it - that way it could at least be combined with xclip and cron-scripted, etc. and not force us to be clumsy with the mouse :)

share|improve this answer
add comment

Redirect it to a file:

$ example-command > ~/output.txt

Where example-command is the command that is producing the output you want to save. The tilde (~) signifies your home directory, so the file output.txt will be under your home folder containing the output of the command.

If you want all output, including errors:

$ example-command > ~/output.txt 2>&1


If you'd like it on your clipboard, you have a few options:

If there isn't a lot of output, you can highlight the output and right click to save it to your clipboard. If there is too much to highlight, pipe it to xclip (you may need to install it depending on your distro):

$ example-command | xclip

xclip allows command line interaction with the X server's clipboard.

share|improve this answer
add comment

use the command 'script'. For usage rtfm.

share|improve this answer
add comment

pbcopy works pretty good :)

add this to your .bashrc or .zshrc

copy { $1 | pbcopy }

This will copy the output of the command to the buffer.

Use Ctrl+V or pbpaste to show the output.

For example:

The command copy pwd

Would output the current directory to the buffer

share|improve this answer
add comment

Pop open gEdit or vi or your favorite text editor, copy, paste, and save.

share|improve this answer
    
Problem is how to copy, too many lines. drag mouse is not a good idea. –  arsane Dec 7 '09 at 6:50
    
why is mouse-dragging a bad idea? are we talking tens of lines, hundreds, or thousands? –  quack quixote Dec 7 '09 at 18:44
add comment

Instead of dragging mouse to select all text, I got a workable way though I not so like it.

  1. triple click the last line of current terminal(do not release the mouse).
  2. press SHIFT+HOME key which will lead us to the first line.
  3. drag mouse to the first line.
  4. right click , edit->copy.
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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