[Gllug] small Wrinkle

Tom Gilbert tom at linuxbrit.co.uk
Sun Feb 3 16:16:03 UTC 2002


* Stig Brautaset (stigbrau at start.no) wrote:
> * Les Till <les_till at cableinet.co.uk> spake thus:
> > I've been writing perl scripts that will convert a comma separated data
> > base file, extracted from a windows application, into a format that will
> > be accepted by postgresql.
> >  The problem of converting dos EOL to Linux had crossed my mind and I
> > have looked around for dos2linux / dos2unix, couldn't find it in my
> > setup so forgot about it.
> >  Needed to get a few lines of the dos file for testing purposes so I
> > used gedit, copy and paste into a new file. Lo and behold I found that
> > all the offending CR's had been removed.
> >  So if you want to do dos2linux just use gedit - edit, 'select all' or
> > 'copy' and 'paste'. I await for replies like 'Yeah we know'  or 'Emacs
> > is betterernat'.
> >  -Les
> 
> 1. Open the file in vi(m), use ":%s/^M//" (the ^M in obtained by C-v C-M)

Actually if you're going to open it in vim, you may as well just change
the fileformat. When you open a dos file in vim, it should say [DOS] on
the status bar, you can then just :set ff=unix and :w and it'll convert
the crlfs for you.

Tom.
-- 
   .^.    .-------------------------------------------------------.
   /V\    | Tom Gilbert, London, England | http://linuxbrit.co.uk |
 /(   )\  | Open Source/UNIX consultant  | tom at linuxbrit.co.uk    |
  ^^-^^   `-------------------------------------------------------'

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list