[comp.unix.shell] typescript and ^M

haozhou@acsu.buffalo.edu (hao zhou) (10/28/90)

Maybe this question was asked before ...

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?

	Thanks ... HaoZ

-- 
Internet:haozhou@acsu.buffalo.edu BITNET:haozhou%acsu.buffalo.edu@UBVM.BITNET
UUCP: uunet!acsu.buffalo.edu!haozhou

kole@convex.com (John P. Kole) (10/28/90)

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----

mark@hsi86.hsi.com (Mark Sicignano) (10/29/90)

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

tr -d '\015' < typescript > newfile

works for me.

-mark
-- 
Mark Sicignano                                  ...!uunet!hsi!mark
3M Health Information Systems                   mark@hsi.com

jeff@onion.pdx.com (Jeff Beadles) (10/29/90)

In <42995@eerie.acsu.Buffalo.EDU> haozhou@acsu.buffalo.edu (hao zhou) writes:
>Maybe this question was asked before ...

It has.  Maybe it's time to add to a faq...

>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?

No, typescript files will have ^M, as it's in the data stream...

Anyway, to remove them within vi, type:

	<ESCAPE>:%s/^V^M$//

(escape colon percent s slash control-v control-m dollar slash slash)

	-Jeff
-- 
Jeff Beadles		jeff@onion.pdx.com