Forrest logo
back to the script tool

script:tldr:3205c

script: Start recording in file named "typescript".
$ script
try on your machine

The command "script" is a command-line utility that allows you to record all activities within a terminal session. When you run the "script" command, it starts a new subshell and records everything that happens within that session, including all terminal input and output.

The basic usage of the "script" command is:

script [OPTIONS] [COMMAND]

Here, OPTIONS refer to various flags and settings that can be passed to the "script" command, and COMMAND represents the specific command or program to run within the script session.

Some common options for the "script" command include:

  • -a: This option appends the output to an existing file instead of creating a new file.
  • -f: It flushes the output after each write, allowing real-time monitoring.
  • -c: It executes the specified command instead of starting an interactive shell.
  • -q: This option suppresses the starting and ending messages.
  • -t: It timestamps each line of the recorded script.

The "script" command starts recording when executed and continues until you terminate the session by entering the "exit" command or pressing Ctrl+D (End of Transmission) to send an end-of-file character.

Once you exit the script session, it saves the recorded output to a file named "typescript" in the current directory (unless you specify a different filename using the -f option). Note that if you run multiple script sessions without specifying a custom filename, each session will overwrite the previous "typescript" file.

The "script" command is often useful for documenting and reviewing terminal sessions, reproducing complex sequences of commands, debugging, and sharing session logs with others.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the script tool