Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Handling ^M's in text files

Re: Handling ^M's in text files

From: Tim Cross <tcross_at_nospam.une.edu.au>
Date: 28 Oct 2002 10:27:53 +1100
Message-ID: <87smyrjwcm.fsf@blind-bat.une.edu.au>


Ubiquitous <weberm_at_polaris.net> writes:

> I'm sure this is a silly question, but sometimes when one FTPs
> files bewteen a DOS and UNIX environment, the "end of line"
> markers show up as "^M" in the file. Is there a utl_file
> package one can use to scrub these from a file? I sppse one
> could rewrite the file sans the last character, but one would
> then have to test for "^M" to keep from dropping characters
> without the markers in it...
>
>

Check what ftp mode you are using.

What you need to do is ftp the files in ASCII or what is sometimes called text mode. With this mode, the correct translation of end of line markers will occur.

Often the problem with ^M is due to files being transferred from a DOS based system to a UNIX system in BINARY mode - binary mode is often the default for many ftp clients. In BINARY mode, no translation is performed. Due to the different end of line indicators used in DOS and UNIX, binary mode transfer results in getting these extra ^M when going form DOS to UNIX (and if you go the other way, when you look at the file under DOS/WINDOWS it will just be one long line).

If you are using SAMBA mounts to share data between WINDOWS/UNIX, there are configuration options which can be used to achieve the correct translations.

If all else fails, the translation can be done witha very simple perl script. Check out Google for scripts called dos2unix.pl and unix2dos.pl (or without the pl extensions for more generalised search).

Tim Received on Sun Oct 27 2002 - 17:27:53 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US