awk -v RS='\r\n' foo.log
Unix 用\n行末结尾
Mac 用\r行末结尾
PC 用 \r\n行末结尾
参考:
https://stackoverflow.com/questions/13069905/awk-print-is-adding-a-control-m-character-at-end-of-line#comment17754368_13069905
The record separator is automatically set to the line-ending of the current system, LF (\n) on the Unix-based systems, CR-LF (\r\n) on MS systems and CR (\r) on Mac OS prior to Mac OS X.
版权声明:可以转载,转载时请务必以超链接形式标明文章 Mac下处理PC以^M结尾的文本 的原始出处和作者信息及本版权声明。
http://www.chedong.com/blog/archives/001499.html