catで改行コードを確認する

恥ずかしながら先ほど知りました。
無知な私はvimで確認しておりました。
vimでMを表示させる方法 - rochefort's blog     

man

CentOSのmanによると-Aで可能。

# man
-A, --show-all
       ‘-vET’ と同じ。

-v, --show-nonprinting
       <LFD> と <TAB> とを除く制御文字を ‘^’ 表記を使って表示する。高位ビットがセットされている文字は、前に ‘M-’ を置いて表わす。

-E, --show-ends
       各行の最後に ‘$’ を表示する。

-T, --show-tabs
       <TAB> 文字を ‘^I’ と表示する。

macBSD系なら)-eで。

#man
-e      Display non-printing characters (see the -v option), and display a dollar sign (`$') at the end of each line.
-v      Display non-printing characters so they are visible.  Control characters print as `^X' for control-X; the delete character (octal 0177)
        prints as `^?'.  Non-ASCII characters (with the high bit set) are printed as `M-' (for meta) followed by the character for the low 7 bits.

手元のmacで試す

$ ll
total 24
-rw-r--r--@ 1 trsw  staff  3  6  7 09:42 cr.txt
-rw-r--r--@ 1 trsw  staff  6  6  7 09:42 crlf.txt
-rw-r--r--@ 1 trsw  staff  3  6  7 09:42 lf.txt

まずはlf。これは普通。

$ cat lf.txt
lf
$ cat -e lf.txt
lf$

続いてcr。catで表示されませんが、-eだとM付きで表示されます。

$ cat cr.txt
$ cat -e cr.txt
cr^M

最後にcrlf。

$ cat crlf.txt
crlf
$ cat -e crlf.txt
crlf^M$

その他

-bと-tは知りませんでした。

-b      Number the non-blank output lines, starting at 1.

-t      Display non-printing characters (see the -v option), and display tab characters as `^I'.