换行符:
windows:’\r\n’
mac: ‘\r’
Linux: ‘\n’
转换方式:
Windows->Linux : sed -i 's/\r$//' file.txt
Windows->Mac : cat old.txt | tr -d "\n" > new.txt
Mac->Windows : cat old.txt | tr "\r" "\n" | sed 's/$/\r/' > new.txt
Mac->Linux : cat old.txt | tr "\r" "\n" > new.txt
Linux->Windows : sed -i 's/$/\r/' file.txt
Linux->Mac : cat old.txt | tr "\n" "\r" > new.txt
需要提醒的是,sed的处理方式是按行处理,对每行处理时\n已被忽略;tr不能替换单子符为多字符,tr "\r" "\r\n"是行不通的。