Linux和Windows文本文件行结束标志不同。Linux文本文件用"\n"(0a)表示回车换行,而Windows用"\r\n"(0d 0a)表示回车换行。因此当Linux使用Windows文本文件时,常常会出现错误。为了避免这种错误,Linux提供了两种文本格式相互转化命令:dos2unix和unix2dos。其中,dos2unix把"\r\n"转化成"\n",而unixtodos把"\n"转化成"\r\n"。
sudo apt-get install tofrodos
todos(相当于unix2dos)和fromdos(相当于dos2unix)
todos Hello.txt (即unix2dos Hello.txt)
fromdos Hello.txt (即dos2unix Hello.txt)
sudo apt-get install tofrodos
todos(相当于unix2dos)和fromdos(相当于dos2unix)
todos Hello.txt (即unix2dos Hello.txt)
fromdos Hello.txt (即dos2unix Hello.txt)