Open In App

script command in Linux with Examples

script command in Linux is used to make typescript or record all the terminal activities. After executing the script command it starts recording everything printed on the screen including the inputs and outputs until exit. By default, all the terminal information is saved in the file typescript , if no argument is given. script is mostly used when we want to capture the output of a command or a set of command while installing a program or the logs generated on the terminal while compiling an opensource codes, etc. script command uses two files i.e. one for the terminal output and other for the timing information. 

Syntax:



script [options] [file]

Example 1: To start a typescript without any argument. If no filename is given as argument, script will automatically create a file namely typescript in the home directory to save the recorded information. 

Input:



  

In order to stop the typescript, we just need to execute exit command and script will stop the capturing process. Since there’s no filename given as argument, the script will automatically create a file namely typescript in the home directory to save the recorded information. 

Output

Example 2: To start the typescript, run any random command and save it in a text file, let’s say geeksforgeeks.txt

Input

 

Output

The output produced above is the content of the file geeksforgeeks.txt, created by script command. 

Options:

scriptreplay --timing=time_log geeksforgeeks1

             Output:

Article Tags :