改行コード #memo
# CRLF を LF に変換
% ruby -i -pe 'sub("\r\n", "\n")' test-crlf.txt
# CRLF を LF に変換 ファイルいっぱい版
% ruby -i -pe 'sub("\r\n", "\n")' crlf-files/**/*(.)
nkf -g foo.txt
*NKF
oldMac, Windows -> Unix
$ nkf -Lu foo.txt > unix.txt
oldMac, Unix -> Windows
$ nkf -Lw foo.txt > windows.txt
*tr
Mac -> Unix
$ tr \\r \\n <mac.txt >unix.txt
Windows -> Unix
$ tr -d \\r <windows.txt >unix.txt
Unix -> Windows
$ perl -p -e 's/\n/\r\n/' <unix.txt >windows.txt