在unix系統(tǒng)中,文本文件默認用\r作為換行符,但是在查看文件時現(xiàn)實成為^M,如下:
>> echo "abc\rdef\rghi\r123\r456\r" >unix.txt
>> less unix.txt
abc^Mdef^Mghi^M123^M456
unix.txt (END)
可以通過tr命令進行替換 tr '\r' '\n' <infile> outfile
>> tr '\r' '\n' <unix.txt> win.txt
>> less win .txt
abc
def
ghi
123
456