in reply to Convert file to unix

A text file on Unix and a text file on Windows are basically the same. With ONE exception, for historical reasons a Windows text line ends in <CR><LF>, Carriage Return, Line Feed, while a Unix text line just ends in <LF>, Line Feed.

Lots of FTP tools like FireFTP know about this and convert automatically. Update: Oh my gosh, I must admit that even Win IE know how to do this.

I don't know how many files that you have to do this with, but say you have used binary ftp to transfer a "dos.text" to a Unix system, Open that file in vi and then save it. That blows way these <CR>'s, in Perl,'C', the \r chars away. That's it.

However normally, if you FTP in "text mode" that happens automatically in either direction for you. Or at least that is very likely. This is NOT "rocket science": to go to Unix from Windows delete the \r characters. To go from Unix to Windows, add a \r before each \n that doesn't already have a \r before it.

Replies are listed 'Best First'.
Re^2: Convert file to unix
by james2vegas (Chaplain) on Aug 19, 2009 at 10:19 UTC
    What version of nvi/vim is this? A co-admin on a server insints on ftping config files back and forth between the server and his windows box where he edits the files in notepad. So all the config files have the ^M disease and opening and saving in nvi or vim does not remove the ^Ms.
      In whatever flavour of vi you choose, type the following at the command (':') prompt i.e. non-visual:
      s,^M,,g w!
      NB The '^M' (<Ctrl> <M>) char is obtained by typing <Ctrl><V><Ctrl><M>...

      A user level that continues to overstate my experience :-))
        The parent claimed that simply resaving should remove the ^Ms