loading...

Record your terminal session using the `script`command.

rderik profile image rderik ・1 min read

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(1).

The 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 script to:

  • 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 typescript.

$ script
% ls
% exit

You can then view the capture by using cat(1):

$ cat typescript

If you are interested in more detail, here are my notes on how to use it:

https://rderik.com/notes/using-the-script-command-to-record-a-terminal-session/

Posted on by:

Discussion

markdown guide
 
 

That's an interesting use of Gists, thanks for sharing!