How to change file format from Unix to DOS using Perl?
Basically I want to 开发者_如何学运维change my file format from Unix to DOS. Is there any way to do it in Perl? Thanks a lot!
perl -Mopen=OUT,:crlf -pi.bak -e0 yourfilename
You can use dos2unix
/unix2dos
commandline tools convert format to each other.
In vim
, also it's simple.
You can read a file in DOS format and write it in Unix format. This will
replace all <CR><NL>
pairs by <NL>
(assuming 'fileformats' includes "dos"): >
:e file
:set fileformat=unix
:w
If you read a file in Unix format and write with DOS format, all <NL>
characters will be replaced with <CR><NL>
(assuming 'fileformats' includes
"unix"): >
:e file
:set fileformat=dos
:w
精彩评论