Search code examples
linuxtee

store all the data in terminal to text file by tee command or equivalent tool


I learnt that a tee command will store the STDOUT to a file as well as outputs to terminal.

But, here the problem is every time I have to give tee command, for every command I give.

Is there any way or tool in linux, so that what ever I run in terminal, it should store the command as well as output. (I used tee command in MySQL, where it will store all the commands and outputs to a file of that entire session. I am expecting a tool similar to this.)

Edit: When I run script -a log.txt, I see ^M characters as well as ^[ and ^] characters in log.txt file. I used various dos2unix, :set ff=unix, :set ff=dos commands, but they didn't helped me in removing these ^[, ^] characters. Is there any method, I can directly get the plain text file (with out these extra chars).

OS: RHEL 5


Solution

  • You can use script command which writes everything on file

    script -f log.txt