title: format output from Unix "script" command: remove backspaces, linefeeds and deleted chars?
body: <p>I'm trying to use the <a href="http://unixhelp.ed.ac.uk/CGI/man-cgi?script" rel="noreferrer"><em>script</em></a> command to record an interactive shell session so that I can use it to prepare documentation.  </p>
  
  <p>according to the man page:</p>
  
  <blockquote>
    <p>Script places everything in the log file, including linefeeds and<br>
    backspaces.  This is not what the naive user expects.</p>
  </blockquote>
  
  <p>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.</p>
  
  <p>example, I run a <em>script</em> session:</p>
  
  <pre><code>stew:~&gt; script -f scriptsession.log
  Script started, file is scriptsession.log
  stew:~&gt; date
  Mon Aug 22 15:00:37 EDT 2011
  stew:~&gt; #extra chars: that
  stew:~&gt; exit
  exit
  Script done, file is scriptsession.log
  </code></pre>
  
  <p>then I use <em>cat</em> to read the session log:</p>
  
  <pre><code>stew:~&gt; cat scriptsession.log
  Script started on Mon 22 Aug 2011 03:00:35 PM EDT
  stew:~&gt; date
  Mon Aug 22 15:00:37 EDT 2011
  stew:~&gt; #extra chars: that
  stew:~&gt; exit
  exit
  
  Script done on Mon 22 Aug 2011 03:01:01 PM EDT
  </code></pre>
  
  <p>but when I use <em>less</em>, I see evidence of the unwanted characters that are invisible using <em>cat</em>:</p>
  
  <pre><code>stew:~&gt; less scriptsession.log
  Script started on Mon 22 Aug 2011 03:00:35 PM EDT
  stew:~&gt; date
  Mon Aug 22 15:00:37 EDT 2011
  stew:~&gt; #extra chars: thiESC[ESC[ESC[ESC[Kthat
  stew:~&gt; exit
  exit
  
  Script done on Mon 22 Aug 2011 03:01:01 PM EDT
  scriptsession.log lines 1-8/8 (END)
  </code></pre>
  
  <p>when I use <em>cat</em>, I understand that it doesn't remove the invisible chars, it just doesn't represent them visibly, like <em>less</em> does--so if I pipe the <em>cat</em> output to a file, it still has the unwanted characters.  </p>
  
  <p>the output format I'd like is a copy of what <em>cat</em> <strong><em>displays</em></strong>.  thanks!</p>
  
  <p>(apologies if this is a duplicate, searching "unix script output format" returns lots of noise results with respect to the question at hand!)</p>