Suppose you are compiling a program and all the error messages, scroll off your screen without giving you time to read.
scriptcommand will come to your aid. Using
scriptit is possible to collect all the error messages scrolling through your screen for later use.
Script Command Syntax
... where, filename is the name of the file in which script saves the terminal messages.
Once the script command is executed, you can continue doing what you were doing like compiling or running a command and so on.
And everything that you see on the screen will be written to the file you supplied with the script command. Once you have finished your task, type exit to terminate the script command.
Script Command Usage
$ script my_log_file Script started, file is my_log_file $ ls -l ... $ ps aux ... $ cat testfile ... $ exit Script done, file is my_log_file
Explanation of the above steps
- You first start the
scriptcommand and pass a file name to it -
scriptwill start logging everything that is written to your terminal, including the output.
- Finally to terminate the
- Later you can open the
my_log_filefile to see the output.
script command can record the output of any Linux command.