I'm trying to use the script command to record an interactive shell session so that I can use it to prepare documentation.
according to the man page:
Script places everything in the log file, including linefeeds and
backspaces. This is not what the naive user expects.
I am the naive user (don't usually get a shout out in man pages, this is rather exciting!), and I'd like to process the output so that backspaces, linefeeds and deleted characters and so on are removed.
example, I run a script session:
stew:~> script -f scriptsession.log
Script started, file is scriptsession.log
stew:~> date
Mon Aug 22 15:00:37 EDT 2011
stew:~> #extra chars: that
stew:~> exit
exit
Script done, file is scriptsession.log
then I use cat to read the session log:
stew:~> cat scriptsession.log
Script started on Mon 22 Aug 2011 03:00:35 PM EDT
stew:~> date
Mon Aug 22 15:00:37 EDT 2011
stew:~> #extra chars: that
stew:~> exit
exit
Script done on Mon 22 Aug 2011 03:01:01 PM EDT
but when I use less, I see evidence of the unwanted characters that are invisible using cat:
stew:~> less scriptsession.log
Script started on Mon 22 Aug 2011 03:00:35 PM EDT
stew:~> date
Mon Aug 22 15:00:37 EDT 2011
stew:~> #extra chars: thiESC[ESC[ESC[ESC[Kthat
stew:~> exit
exit
Script done on Mon 22 Aug 2011 03:01:01 PM EDT
scriptsession.log lines 1-8/8 (END)
when I use cat, I understand that it doesn't remove the invisible chars, it just doesn't represent them visibly, like less does--so if I pipe the cat output to a file, it still has the unwanted characters.
the output format I'd like is a copy of what cat displays. thanks!
(apologies if this is a duplicate, searching "unix script output format" returns lots of noise results with respect to the question at hand!)