in reply to crlf to \n

Since it hasn't been mentioned, and for completeness (planetscape's methods would be my recommendation for automated solutions):

1. load file into vi 2. in command mode: %s/^V^M//g (^V is literal mode, then add carriage return, or ^M) 3. save file.
This might work with vim if you use vi compatibility mode; vim -C iirc. Otherwise vim tends to ignore eol differences.

Update: Windows is not absolutely bound to crlf eols either. Load a Unix file into wordpad sometime. That's the classic unix eol test in Win32: looks funny in notepad, looks fine in wordpad.

Replies are listed 'Best First'.
Re^2: crlf to \n
by zwon (Abbot) on Apr 02, 2009 at 19:09 UTC

    In vim you can use 'set ff=dos' or 'set ff=unix' to save file with desired line-endings. So you can load file into vim, type :set ff=unix, and save file.

      It's possibly worth noting that merely changing the filetype fileformat (ff) in Vim won't repair a file which has a mix of *nix and dos line-endings, and because of the still massive userbase of a few specific Microsoft tools (that are brain-dead on this score), such files are rather commonly encountered. In such a case one has to actively do something, and if one wants to do something inside Vim, it ought to work to do what dwm042 wrote in reply above.