changing a ! to a \nC where \n is a newline

Bob McGowen x4312 dept208 bob at wyse.wyse.com
Fri Sep 21 08:15:43 AEST 1990


In article <13894 at hydra.gatech.EDU> gt0178a at prism.gatech.EDU (BURNS,JIM) writes:
>in article <2962 at wyse.wyse.com>, bob at wyse.wyse.com (Bob McGowen x4312 dept208) says:
>> In article <1990Sep18.023649.1336 at virtech.uucp> cpcahil at virtech.UUCP (Conor P. Cahill) writes:
>>   >:1,$s/!/<ctrl>-V<Return>C/g	(this will appear as:1,$s/!/^MC/g)
>> This will put carriage returns in the file, not newlines.
>
>I thought so too at first, but it works on Dynix and SunOS 4.0.3. Probably
>has something to do w/ the equivalent of an 'stty icrnl' mode that vi sets
>when executed.

Interesting.  When I get a copy of a DOS format text file (in native format)
and look at it with vi, each line has a "^M" at its end.  My file command
reports this file as a DOS format text file.  If I take a UNIX text file
into vi and do a global substitute:

	%s/$/^-V<CR>/    #  what I see: %s/$/^M/

I get ^M displayed at the end of each line.  Saving this and then running
the file command on it tells me I have a DOS format text file, ie one
with carriage return/linefeed at the end of each line.

If the input ^M were made into a linefeed the file should still be UNIX
only double spaced (in this example).  So under XENIX 2.[23].x and AT&T
UNIX SysV/386 Rel 3.2 there is no conversion of cr to nl set by vi.
Other systems may do this and I would be interested in knowing which ones.

Bob McGowan  (standard disclaimer, these are my own ...)
Product Support, Wyse Technology, San Jose, CA
..!uunet!wyse!bob
bob at wyse.com



More information about the Comp.unix.shell mailing list