How to log all that is displayed in my console to a file
It is difficult to keep track of all that is printed in the console session especially if you are debugging a program with lots of debug messages. In such cases, you can use “script” command which spawns a new shell and all the activity on that shell is logged to a file until the shell is closed using “exit” command. By default, the “script” command stores the log in a file “typescript” which is stored in the same directory where the “script” command is run. Once you close the shell newly spawed by “script” command you will go back to the old shell prompt. If you want all the captured log to be stored in a specific file, you can pass the file name as an argument to “script” command. The following example shows how to use it.
[neo@techpulp ~]# script mylog.txt Script started, file is mylog.txt [neo@techpulp ~]# cd Examples/ [neo@techpulp Examples]# ls 1.txt 2.txt dir1 ex1.c ex2.c [neo@techpulp Examples]# exit Script done, file is mylog.txt [neo@techpulp ~]# [neo@techpulp ~]# cat mylog.txt Script started on Mon 08 Dec 2008 08:20:15 PM IST [neo@techpulp ~]# cd Examples/ [neo@techpulp Examples]# ls 1.txt 2.txt dir1 ex1.c ex2.c [neo@techpulp Examples]# exit Script done on Mon 08 Dec 2008 08:20:25 PM IST [neo@techpulp ~]#

