I've been in the situation where I ran a script that behaved weirdly and would love to be able to "replay" what I did to figure out what went wrong. A useful command for those cases is
script command (introduced in 1979) allows you to record a terminal session to a file. You can later check and reference that file to analyse it as you please. Or maybe record your terminal as a demo.
As with any other Unix command, the power comes from your creativity on how to use it. You can use
- Record a demo.
- Capture output.
- Record session to report a bug.
You can try it just by typing
script in your terminal. It opens up a new shell that will be recorded. By default, the session is saved in a file named
$ script % ls % exit
You can then view the capture by using
$ cat typescript
If you are interested in more detail, here are my notes on how to use it: