回车换行命令一直很诡异,今天花了点时间 研究了下,
符号标示:
回车:/r <--> CR(Carriage Return, 0×0D)
换行:/n <--> LF(Line Feed, 0×0A)
dos/windows : /r/n
unix/linux : /n
max : /r
至于历史,主要是电报传输讯息年代传下来的,有时间慢慢研究
这里主要介绍他们之间的转换:
vim命令
dos->unix/linux :set fileformat=unix
unix/linux->dos :set fileformat=dos
sed
dos->unix sed 's/.$//' dosfile > unixfile
unix-> dos sed 's/$/\r/' unixfile > dosfile
perl
dos->unix perl -p -e 's/\r$//' < dosfile > unixfile
unix->dos perl -p -e 's/$/\r/' < unixfile > dosfile
符号标示:
回车:/r <--> CR(Carriage Return, 0×0D)
换行:/n <--> LF(Line Feed, 0×0A)
dos/windows : /r/n
unix/linux : /n
max : /r
至于历史,主要是电报传输讯息年代传下来的,有时间慢慢研究
这里主要介绍他们之间的转换:
vim命令
dos->unix/linux :set fileformat=unix
unix/linux->dos :set fileformat=dos
sed
dos->unix sed 's/.$//' dosfile > unixfile
unix-> dos sed 's/$/\r/' unixfile > dosfile
perl
dos->unix perl -p -e 's/\r$//' < dosfile > unixfile
unix->dos perl -p -e 's/$/\r/' < unixfile > dosfile