Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a problem. An application has spat a whole load of log text into a Shell window that needs to be captured. If we could skip passed the "probably shouldn't have had an application output it's stdout anywhere other than a log file", is there a tool/command that I can use to capture the program output?

Other than highlighting all of the text with a mouse and copying to a text file. There are 250,000 lines... :)

share|improve this question
Can you run it again and redirect into a text file? myprog > log.txt – jonsca Jul 25 '11 at 7:58
I think if I suggest that to the offending admin he might pop. I have since discovered a method of setting selection markers on the window with the right click menu. This way I can easily select the area of text I am interested in. Then copy and paste. Not a quick task, just getting in onto the clipboard seems to take 5 minutes! I'm interested to hear any other answers though, so I'm not answering my own question. There must be a better way! – tigerswithguitars Jul 25 '11 at 8:12
The shell only executes commands. The window is a terminal. And it would help if you told us which terminal program you are using. From OpenSuSE I'm guessing it's KDE Konsole, which has File - Save Output As. – grawity Jul 25 '11 at 8:13
Many apologies, you are right grawity. I am using KDE Konsole... but I have no file menu option, I have; session, edit, view, bookmarks, settings, help. None of which have a save output, annoyingly. – tigerswithguitars Jul 25 '11 at 8:39
@tigers: It must be a different Konsole version than the one I have (2.6.4, KDE 4.6.5). Can't offer any more suggestions :( – grawity Jul 25 '11 at 9:01
up vote 1 down vote accepted

If you can run the program again, you have 3 options:

  1. If you don't need to see the output as the program runs, use simple redirection (as jonsca has already suggested) :

    $ yourVerboseProgram > anyNameForYourLogFile

  2. If you want to see the program's output as it runs, you have two (at least) options:

    a) Run it as described above, while in a second terminal running tail -f yourLogFile

    b) ('b' for 'better') Use tee:

    $ yourVerboseProgram | tee anyNameForYourLogFile

  3. If 2. applies and the program is interactive (needs your input as it runs), use the script program:

    $ script aLogFile.log
    Script started, file is aLogFile.log
    $ yourVerboseProgram

    (the program running... And exiting.) Then you exit the script:

    $ exit
    Script done, file is aLogFile.log

    The only problem with option 3 is that everything is being logged, including your keystrokes like pressing "Backspace" etc.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .