How to convert CR to LF in a big file?

Hello Friends,

I have a big file that is transferred to my UNIX system and it seems it has CR as the line delimiter

When I run

file <filename> 
<filename>: ASCII text, with CR line terminators 

How do I convert the file to one with LF as terminators so that my code that runs on UNIX can read it properly?

What version of Unix are you on? What is the Operating System on the originating system? How is the file being transferred?

Andrew

It might be on the FTP (if that's how you move it) Setting the mode to ASCII for the transfer might help.

You might also use sed to edit the file or dos2unix if that is installed.

If you open it with vi, do you see control characters that show up as ^M It's a common enough problem.

Robin

If it has CR terminators (old Apple style), you should be able to use:

tr '\r' '\n' < infile > outfile

If it has CRLF terminators (Windows style) you could use:

tr -d '\r' < infile > outfile