bash script command - ghdrako/doc_snipets GitHub Wiki

script is used to take a copy of everything which is output to the terminal and place it in a log file. It should be followed by the name of the file to place the log in, and the exit command should be used to stop logging and close the file.

It can be used to obtain a copy of a program run, which should be placed in your notebook and will be a required part of an assignment submission.

Everything between the script and the exit command is logged to the file. This includes the confirmation messages from script itself.

script [ -a ] [ filename ]
  • no log file name is given, it just uses a default name, typescript.
  • the log file already exists, it just overwrites the old file.*
  • -a append to the old file not overwrites

Record and replay terminal session

### Record session
# 1)
script -t 2>~/session.time -a ~/session.log

# 2)
script --timing=session.time session.log

### Replay session
scriptreplay --timing=session.time session.log