The file written by script during a router session contains
backspaces.

For example:

$cat -A xx
AC6509#sho proc cpu | e 0.0.^H ^H0^M$
AC6509#sho te h^H ^H^H ^Hch^M$

In order to share the file with Windows users, the backspaces
need to be removed. The file should be a WYSIWYG of cat:

$cat xx
AC6509#sho proc cpu | e 0.00
AC6509#sho tech

Web searches and experimenting with various command options
and pipes didn't solve the problem.

I wrote the following to remove the backspaces:

#!/bin/bash
while :
do
  if ( egrep -m1 ^H xx > /dev/null )
  then
     sed -i 's/.^H//' xx
  else
     exit
  fi
done
  sed -i 's/^M//' xx

Is there an easier solution using Linux commands?


Thad