This is the procedure for documenting input commands and output on the console, terminal or in shell to a text file with the default typescript utility SCRIPT.
What is SCRIPT?
SCRIPT is a default FreeBSD and UNIX utility, that makes a typescript of a terminal session. It works on the console, on terminals and in a shell. The typescript is stored in a text file, that serves as documentation later.
Make typescript with SCRIPT.
In this example, input and output is written to the script text file test.txt for later documentation.
$ script test.txt
Script started, output file is test.txt
$ date
Fri Sep 5 13:52:51 CEST 2025
$ freebsd-version
14.3-RELEASE-p2
$ exit
Script done, output file is test.txt
Additional input and output can be appended to the script. This avoids overwriting the initial script.
$ script -a test.txt
Script started, output file is test.txt
Review typescript from SCRIPT.
The script can later be reviewed with default utilities or even replayed by SCRIPT itself.
$ cat test.txt
Script started on Fri Sep 5 13:52:48 2025
$ date
Fri Sep 5 13:52:51 CEST 2025
$ freebsd-version
14.3-RELEASE-p2
$ exit
Script done on Fri Sep 5 13:53:13 2025
Manual for SCRIPT.
See the manual for features, such as realtime playback and similar features.
$ man script