Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I viewed this question to redirect text to file while displaying the output. My question is how can I redirect it while working AND without constant | tee command.

My plan is to use this question to identify terminal (Gnome or Guake) and record only Gnome for my Linux commands testing. So I need constant and immediate redirecting of commands and their outputs (with errors) to a file (say cmdlog.log).

share|improve this question

marked as duplicate by Seth Dec 9 '14 at 3:54

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.

1 Answer 1

up vote 2 down vote accepted

The script command can do this, it starts a session and all output is by default captured into a file called typescript. Alternatively, one can specify the filename to contain the captured session, e.g.

script capture.txt

..then run your commands and finally type "exit" to exit the session.

To ensure you don't get any control characters, use:

script capture.txt

and when you exit, use:

col -b < capture.txt > cleaned-capture.txt
share|improve this answer
That works but how do I tell it to not to use colour while recording as it gives unknown characters while using gedit. –  VedVals Nov 12 '12 at 18:51
I've updated my answer. –  Colin Ian King Nov 12 '12 at 19:20
OK. Now there are no unknown characters. Still need to remove colour tags though. Maybe I'll do it manually using tr command. –  VedVals Nov 13 '12 at 13:10

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