[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: AWK: adds "^M" at the end of line?




One more thing can be tried if its a pb with DOS files.
Use dos2unix  to convert the dos files to unix  and then try this awk !!

RCP







Chris Kenrick <chrisk@aurema.com> on 06/25/2002 07:47:54 AM
                                                              
                                                              
                                                              
  To:          Debian User List                               
               <debian-user@lists.debian.org>                 
                                                              
  cc:          (bcc: Ramesh Pathak/Satyam)                    
                                                              
                                                              
                                                              
  Subject      Re: AWK: adds "^M" at the end of line?         
  :                                                           
                                                              







On Tue, Jun 25, 2002 at 12:08:34PM +1000, Matthew Dalton wrote:
> > On Mon, Jun 24, 2002 at 05:10:15AM -0400, Abdul Latip wrote:
> > > > What file are you trying to read.  If it is mail coming from fetchmail,
> > > > there were some change which causes ^M in mail file.
> > >
> > > It is ftp://ftp.isi.edu/in-notes/rfc-index.txt
> > > I believe that that file does not have ^Ms.
> > > Basically, what I am doing (once in a while), to get
> > > a recent rfc-index file, and merging each rfc description
> > > (1-3 lines) into one line. The script is actually simple
> > > and stupid.
>
> The original file is a dos format text file. Dos text files have CR-LF
> at the end of every line, whereas unix files only have LF. The extra CR
> is the ^M you're seeing. Obviously awk (mawk?) is not handling the text
> format properly, instead assuming it is a unix format file. Your belief
> that the original file does not have ^Ms is incorrect. It does have
> them, but they just don't show up on most editors. If you edit it with
> nvi, you'll see them there.
>
> I'd suggest one of two things:
> 1. If your awk is mawk, try installing gawk (GNU awk) and see if that
> handles dos text files better.
> 2. Convert the files by removing the ^Ms before running awk on them.
>
> This is basically a compatibility problem, not a bug in awk.
>
> Matthew

I'd add a third option.  Assuming the FTP server is configured properly,
transfer the file as ascii rather than binary, and it should do the
conversion properly for you.  I tested with this particular file
transferring as ASCII, and it worked transparently.

- Chris


--
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org





-- 
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org



Reply to: