[comp.editors] VI - removing control characters

tim@ncrcan.Toronto.NCR.COM (Tim Nelson) (09/20/89)

ola y'all,

I have not been able to solve the following problem:

I have files which have a visible ^M (real control M, not up-arrow M)
at the end of every line.  This ^M is making all my files double space
when I print them.  I have been able to remove the real <cr> character,
from within vi, but that leaves the visible ^M; it solves the problem
of double spacing, but is not quite a good solution.
I want to be rid of the visible ^M.

I have also attempted to use "tr", but the terminal is interpreting
"^M" as a carriage control.  I can't seem to escape the "^M".

Anybody have any ideas?

       thanx & later,

=================
tim (nelson)     | uucp        ...!uunet!attcan!ncrcan!tim
ncr canada       | internet     tim@ncrcan.Toronto.NCR.COM
(416) 826-9000   | 6865 Century Ave, Mississauga, Ontario, Canada L5N 2E2
=================
* Have a good day, and a great forever.

cpcahil@virtech.UUCP (Conor P. Cahill) (09/21/89)

In article <1600@ncrcan.Toronto.NCR.COM>, tim@ncrcan.Toronto.NCR.COM (Tim Nelson) writes:
> I have files which have a visible ^M (real control M, not up-arrow M)
> I want to be rid of the visible ^M.

You can use the following sequence:	:1,$ s/<CTRL-V><CTRL-M>//g

it will appear as:			:1,$ s/^M//g



-- 
+-----------------------------------------------------------------------+
| Conor P. Cahill     uunet!virtech!cpcahil      	703-430-9247	!
| Virtual Technologies Inc.,    P. O. Box 876,   Sterling, VA 22170     |
+-----------------------------------------------------------------------+

bill@bilver.UUCP (Bill Vermillion) (09/21/89)

In article <1600@ncrcan.Toronto.NCR.COM-> tim@ncrcan.Toronto.NCR.COM (Tim Nelson) writes:
->I have files which have a visible ^M (real control M, not up-arrow M)
->at the end of every line.  This ^M is making all my files double space
->when I print them.  I have been able to remove the real <cr> character,
->from within vi, but that leaves the visible ^M; it solves the problem
->of double spacing, but is not quite a good solution.
->I want to be rid of the visible ^M.
->
->I have also attempted to use "tr", but the terminal is interpreting
->"^M" as a carriage control.  I can't seem to escape the "^M".
->

tr works for me - just try it the following way

tr -d "\015" <infile >outfile

-- 
Bill Vermillion - UUCP: {uiucuxc,hoptoad,petsd}!peora!tarpit!bilver!bill
                      : bill@bilver.UUCP

aem@ibiza.cs.miami.edu (a.e.mossberg) (09/21/89)

cpcahil@virtech.UUCP (Conor P. Cahill) writes:

>In article <1600@ncrcan.Toronto.NCR.COM>, tim@ncrcan.Toronto.NCR.COM (Tim Nelson) writes:
>>[has ^M at the end of every line in a file]

>You can use the following sequence:	:1,$ s/<CTRL-V><CTRL-M>//g

Hmmm, I think a better way is:

:g/^V^M$/s///

(Real control-v and control-m, of course)

Remember, the original problem is that they're at the end of lines.

Typically, this problem is encountered when using 'script'

aem
a.e.mossberg / aem@mthvax.cs.miami.edu / aem@umiami.BITNET / Pahayokee Bioregion
If I loved a woman, the more I loved her, the more I wanted to hurt her.
								- Diego Rivera

mday@ohs.UUCP (Matthew T. Day) (09/22/89)

From article <1600@ncrcan.Toronto.NCR.COM>, by tim@ncrcan.Toronto.NCR.COM (Tim Nelson):
> I have files which have a visible ^M (real control M, not up-arrow M)
> at the end of every line.  This ^M is making all my files double space
> when I print them.  I have been able to remove the real <cr> character,
> from within vi, but that leaves the visible ^M; it solves the problem
> of double spacing, but is not quite a good solution.
> I want to be rid of the visible ^M.

In "vi":
:1,$ s/^V^M$//g

Sometimes, in the csh of tcsh, you can use ^V on the command line to
escape a character, that way you could use tr.
-- 
+---------------------------------------------------------------------+
| Matthew T. Day, Sanyo/Icon International, Orem, UT (801) 225-6888   |
| Unix System Programmer, ..!uunet!iconsys!mday (mday@iconsys.uu.net) |
+---------------------------------------------------------------------+