How do you effectively use the 'script' command to record an interactive shell?
I have been looking at this reference and trying to work out how to actually use the 'script' command. Can someone give me an example usage? All I've been able to do so far is create a blank text file eg script myChosenFileName
, but it records nothing.
A bit more info:
I want to record all the output from my translations in an interactive shell for future reference. An example command to open this would be trans -I {de=en}
I am sure that this would be an easy question for someone with more CLI experience than me. (I feel a bit silly having the reference right in front of me and still not managing...)
Thanks!
Solution 1:
While the script
manpage has no example usage, the related scriptreplay
manpage does have one:
% script -t 2> timingfile
Script started, file is typescript
% ls
<etc, etc>
% exit
Script done, file is typescript
% scriptreplay timingfile
Essentially, script
is run once at the beginning of the session, with an optional filename (if none given, the default is called typescript
). The problem with script
is that it's an exact copy of everything that happens, so if you try to view the file directly, you will have problems (which is why the scriptreplay
command is useful - or you could simply cat
the file).
For your purposes, it might be better, if more verbose, to use a command like tee
:
trans .. | tee some-file