Files and Filesystems: Determining the End of Line Character for a File

You would like to find out which end of line characters are used in a file. Run a command similar to the following:

For a DOS file, you get:

For a UNIX file, you get:

Where cr is a carriage return (\r), and nl is a newline (\n).

Alternatively,

gives the slightly more logical output of

for a DOS file, or

for a UNIX file.

Mac files terminate with \r only.