Forrest logo
back to the script tool

script:tldr:693bc

script: Append to an existing file.
$ script -a ${logfile-log}
try on your machine

The command script -a ${logfile-log} is used to start a new shell session and record all the activities within that session into a log file.

Here is a breakdown of the different parts of the command:

  • script: It is a command-line utility in Unix-like operating systems that starts a new shell session and records everything that happens within that session.
  • -a: This is an option for the script command, which tells it to append the session output to an existing log file if it already exists, rather than overwriting it. If the log file doesn't exist, it will create a new one.
  • ${logfile-log}: This is a variable or placeholder for the name of the log file. It implies that the log file name is stored in a variable called logfile-log. The actual value of the variable would be substituted in this place, e.g., script -a mylog.txt.

So, when you run this command, it will initiate a new shell session and record all the commands and their outputs in real-time into the specified log file. If the log file already exists, it will append the new session's output to the existing log file.

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