Path: utzoo!attcan!uunet!convex!kole From: kole@convex.com (John P. Kole) Newsgroups: comp.unix.shell Subject: Re: typescript and ^M Message-ID: <107819@convex.convex.com> Date: 28 Oct 90 15:43:04 GMT References: <42995@eerie.acsu.Buffalo.EDU> Sender: news@convex.com Organization: Convex Computer Corporation, Richardson, Tx. Lines: 67 In article <42995@eerie.acsu.Buffalo.EDU> haozhou@acsu.buffalo.edu (hao zhou) writes: >Anyway I wonder if there is any filter I can use to get rid of ^M >(RETURN) in the typescript file. One way I can do it is to replace all >^M with null in emacs or vi. Is there any better way of doing this? In >other words, is it possible to create a typescript without CR chars? The are other annoying characters in typescript files besides ^M. Here is a script I use to remove most of them from csh typescript files (I believe that tcsh puts different annoying characters). I just type 'fixcshscript' and it defaults to typescript. You must redirect stdout to the new file. The ^M is removed via 'tr' within the csh script 'fixcshscript'. All others, including ones you may want to add, are done via the sed script fixcshscript.sed which is invoked from fixcshscript after the ^M are removed. Happy scripting, jpkole ----File: fixcshscript----cut here---- #!/bin/csh -f #----------------------------------------------------------------------- # FILE: fixcshscript # AUTHOR: John P. Kole # DESCRIPTION: Script used to clean up a typescript file from csh. # Outputs to stdout. # EXAMPLE: % script # ...session being recorded... # % exit # % fixcshscript typescript # - or - # % fixcshscript (defaults to typescript) #----------------------------------------------------------------------- set dir = `whence $0` set sedf = $dir:h/fixcshscript.sed if ($#argv == 0) then set script = typescript else if ($#argv == 1) then set script = $1 else set pgm = $0 echo "usage: $pgm:t [ script-file ]" exit 1 endif tr -d '\015' < $script | sed -f $sedf #[The End]# ----End of fixcshscript----cut here---- ----File: fixcshscript.sed----cut here---- #----------------------------------------------------------------------- # FILE: fixcshscript.sed # AUTHOR: John P. Kole # DESCRIPTION: Sed script used to clean up a typescript file from csh. # EXAMPLE: % script # ...session being recorded... # % sed -f fixcshscript.sed typescript #----------------------------------------------------------------------- s/ //g :again s/[^]//g t again #[The End]# ----End of fixcshscript.sed----cut here----