Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 Oct 2006 04:18:57 +0300
From:      Tsampros Leonidas <ltsampros@upnet.gr>
To:        Jerry McAllister <jerrymc@msu.edu>
Cc:        Noah <admin2@enabled.com>, freebsd-questions@freebsd.org
Subject:   Re: replacing ^M with emacs
Message-ID:  <20061028011857.GA31746@biftekaki.lan>
In-Reply-To: <20061027213034.GD98266@gizmo.acns.msu.edu>
References:  <45425D61.6030209@enabled.com> <20061027213034.GD98266@gizmo.acns.msu.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Oct 27, 2006 at 05:30:34PM -0400, Jerry McAllister wrote:
> On Fri, Oct 27, 2006 at 12:26:25PM -0700, Noah wrote:
> 
> > Hi there,
> > 
> > It appears that a text editor placed a bunch on ^M throughout a text 
> > file I am working with.  I assure this is equivalent to eh keystroke 
> > control-M.
> 
> This is probably "MS-DOS" type text file.   MS text file lines
> all end in a CR-LF character pair whereas UNIX text file lines
> have only a LF (line feed) and the end of each line.
> All text editors on MS systems do that and if you do a binary transfer
> of a file from MS to UNIX you will get all the extra ^M characters
> showing up.   most versions of ftp have an ASCII mode that will
> do the conversion for you as you transfer the file back and forth
> between MS and UNIX.   I think SCP only does binary transfers.
> 
> I am not an Emacs user, but,
> You can easily use tr(1) to remove all the ^M characters from a 
> file.    tr -r "\r" <badfile >goodfile
> where badfile is the one with the ^M characters and goodfile is
> the newly cleaned copy.   The only anoying thing is having to 
> write to a second file and then get rid of the first or mv the 
> new one back to the old (as in:   mv goodfile badfile   after doing
> the tr.
> 
> ////jerry
> 


I think there is something similar in emacs by using the
set-buffer-file-coding-system (binded at C-x RET f in default
configurations).

So to "cure" and succesfully "convert" DOS files into unix format, i
use C-x RET f unix RET.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20061028011857.GA31746>