typescript and ^M

John P. Kole kole at convex.com
Mon Oct 29 02:43:04 AEST 1990


In article <42995 at eerie.acsu.Buffalo.EDU> haozhou at 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----



More information about the Comp.unix.shell mailing list