getting rid of ^M

Thomas Wildeman twildeman at deltasd.bc.ca
Fri Sep 1 12:22:26 PDT 2006


openbsd-newbies at sfobug.org on Friday, September 1, 2006 at 12:00 PM -0800
wrote:
>Send Openbsd-newbies mailing list submissions to
>	openbsd-newbies at sfobug.org
>
>To subscribe or unsubscribe via the World Wide Web, visit
>	http://mailman.theapt.org/listinfo/openbsd-newbies
>or, via email, send a message with subject or body 'help' to
>	openbsd-newbies-request at sfobug.org
>
>You can reach the person managing the list at
>	openbsd-newbies-owner at sfobug.org
>
>When replying, please edit your Subject line so it is more specific
>than "Re: Contents of Openbsd-newbies digest..."
>
>
>Today's Topics:
>
>   1. getting rid of ^M (Craig Hammond)
>   2. Re: getting rid of ^M (Florin Iamandi)
>   3. RE: Re: getting rid of ^M (tony at servacorp.com)
>
>
>----------------------------------------------------------------------
>
>Message: 1
>Date: Fri, 1 Sep 2006 18:21:22 +1000
>From: "Craig Hammond" <Craig at sbisolutions.com.au>
>Subject: getting rid of ^M
>To: <openbsd-newbies at sfobug.org>
>Message-ID:
>	<492EA8BEAD97E5438E728A1725861738250D53 at sbserver.sbisolutions.com.au>
>Content-Type: text/plain; charset="us-ascii"
>
>Hi,
>After FTPing a heap of files from Windows to OBSD, I have found that
>a lot of the text them have a ^M at the end of each line. Is there any
>easy way
>to recursively strip out the ^M of all affected files in a number of
>directories.
> 
>I've searched around and tried various dos-unix utilities both on the
>windows
>and the obsd box but i'm not having much luck yet.
> 
>Thanks,
>Craig.
> 
> 
>-------------- next part --------------
>An HTML attachment was scrubbed...
>URL:
>http://mailman.theapt.org/pipermail/openbsd-newbies/attachments/20060901/74d28c22/attachment-0001.html
>
>------------------------------
>
>Message: 2
>Date: Fri, 1 Sep 2006 10:42:55 +0200
>From: Florin Iamandi <florin.i at tiscali.it>
>Subject: Re: getting rid of ^M
>To: openbsd-newbies at sfobug.org
>Message-ID: <20060901084255.GA2242 at roses>
>Content-Type: text/plain; charset="us-ascii"
>
>Craig Hammond dixit (2006-09-01, 10:20:04):
>
>> After FTPing a heap of files from Windows to OBSD, I have found that a
>> lot of the text them have a ^M at the end of each line. Is there any
>> easy way to recursively strip out the ^M of all affected files in a
>> number of directories.
>
>Use something like this, where ^M is obtained by pressing CTRL-V
>followed by CTRL-M:
>
>for i in `ls`; do sed 's/^M//g' $i > $i.new;done
>
>-- 
>Digitally yours,
>Florin Iamandi (Slippery)
>Reason is the first victim of emotion. -- Scytale, Dune Messiah
>
>-------------- next part --------------
>A non-text attachment was scrubbed...
>Name: not available
>Type: application/pgp-signature
>Size: 189 bytes
>Desc: not available
>Url :
>http://mailman.theapt.org/pipermail/openbsd-newbies/attachments/20060901/391c0811/attachment-0001.bin
>
>------------------------------
>
>Message: 3
>Date: Fri, 01 Sep 2006 04:58:26 -0400
>From: tony at servacorp.com
>Subject: RE: Re: getting rid of ^M
>To: florin.i at tiscali.it, florin.i at tiscali.it,
>	openbsd-newbies at sfobug.org
>Message-ID: <200609010858.k818wRnw037460 at mmm1406.sanjose14-verio.com>
>Content-Type: text/plain; charset="US-ASCII"
>
>florin.i at tiscali.it wrote:
>>
>>--0OAP2g/MAC+5xKAE
>>Content-Type: text/plain; charset=us-ascii
>>Content-Disposition: inline
>>
>>Craig Hammond dixit (2006-09-01, 10:20:04):
>>
>>> After FTPing a heap of files from Windows to
>>OBSD, I have found that a
>>> lot of the text them have a ^M at the end of each
>>line. Is there any
>>> easy way to recursively strip out the ^M of all
>>affected files in a
>>> number of directories.
>>
>>Use something like this, where ^M is obtained by
>>pressing CTRL-V
>>followed by CTRL-M:
>>
>>for i in `ls`; do sed 's/^M//g' $i > $i.new;done
>>
>
>This may be an OUCH
>
>DOS text lines end with <Carriage-Return><Line-Feed>
>UNIX text lines end with <Line-Feed>
>Apple text lines end with <Carriage-Return>  (or some such)
>
>FTP transfers from one kind of system to another will take care of the
>different line-endings on an ASCII transfer.
>An ASCII transfer of a binary file tends to wreck the file. Getting rid
>of all the Carriage-Returns (anywhere in the file) would do even more
>damage.
>
>Unixy systems may have a pair of dos2unix and unix2dos programs designed
>to convert text files from one kind to the other.

Hello,

Try using these aliases, just put them in your .profile if you use ksh:>

alias m2u='tr '\''\015'\'' '\''\012'\'''
alias u2m='tr '\''\012'\'' '\''\015'\'''

I hope that helps,

Thomas Wildeman

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.theapt.org/pipermail/openbsd-newbies/attachments/20060901/8c9fbffd/attachment.html


More information about the Openbsd-newbies mailing list