script
script linux command cheatsheet by Thamizhiniyan C S
Introduction
script
command makes a typescript of everything on your terminal session. The terminal data are stored in raw form to the log file and information about timing to another (optional) structured log file.
Syntax
script [options] [file]
Important Flags
Flag | Description |
---|---|
| log stdin to file |
| log stdout to file (default) |
| log stdin and stdout to file |
| log timing information to file |
| deprecated alias to -T (default file is stderr) |
| force to 'classic' or 'advanced' format |
| append to the log file |
| run command rather than interactive shell |
| return exit code of the child process |
| run flush after each write |
| use output file even when it is a link |
| echo input in session (auto, always or never) |
| terminate if output files exceed size |
| be quiet |
| display this help |
| display version |
Examples
Command | Description |
---|---|
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. | |
This command starts a new recording session, with the output stored in the 'mysession.log' file. | |
This command records the terminal session and saves the output into a file with the current date as part of the name. | |
In order to stop the typescript, we just need to execute exit command and script will stop the capturing process. | |
To start the typescript, run any random command and save it in a text file, let’s say filename.txt. | |
To get the typescript of cal command. | |
This command runs 'ls -la' and records its output into 'directory_listing.log' file. | |
This command runs 'ls -la', displays its output and simultaneously saves it into 'file.log'. | |
This option is used to run flush output after each write. | |
This option allows default output file i.e. typescript to be hard or symbolic link. | |
Display this help and exit. | |
This option does not display the notification stating that the script has started and quietly execute and exit the script command. | |
This option allows user to capture the terminal activity step by step and appears like a video when the recorded file is executed with the help of scriptreplay command. | |
To replay the captured terminal activity. | |
Output version information and exit. |
Last updated