Câu trả lời của bạn để sử dụng dos2unix và unix2dos là tuyệt vời.
Đây là một cách khác dựa trên câu trả lời của bạn.
Bạn có thể sử dụng Gnuwin32 mặc dù đủ vui để gói Gnuwin32 có các lệnh là Cygutils http://gnuwin32.sourceforge.net/packages/cygutils.htmlm để sau đó bạn sẽ nhận được unix2dos.exe và dos2unix.exe trong C: \ Files Files .... \ GnuWin32 \ bin và với điều đó trong ĐƯỜNG của bạn.
C:\somedir>dir<ENTER>
Volume in drive C has no label.
Volume Serial Number is DC46-3C68
Directory of C:\somedir
05/23/2014 01:10 AM <DIR> .
05/23/2014 01:10 AM <DIR> ..
05/23/2014 01:10 AM 4 file1
1 File(s) 4 bytes
3 Dir(s) 196,129,951,744 bytes free
Do this command to go from dos2unix
C:\somedir>for %f in (*) do dos2unix %f <ENTER>
C:\somedir>dos2unix file1 <-- This runs automatically from you doing the above command
file1: done.
And do this command to go from unix2dos
C:\somedir>for %f in (*) do unix2dos %f <ENTER>
C:\somedir>unix2dos file1 <-- This runs automatically from you doing the above command
file1: done.
C:\somedir>
Và để kiểm tra xem% f của bạn có làm được điều bạn muốn hay không, sau đó sử dụng echo hoặc @ECHO, ví dụ:
% f in (*) do @ECHO unix2dos% f
Và bạn có thể sử dụng xxd để tạo các tệp và kiểm tra chúng được chuyển đổi. xxd cho windows đi kèm với VIM C: \ Chương trình "" Files \ vim \ vim74 \ xxd.exe
so, i'll create a file, I like this style of command is it allows me to
create whateer file I want, a dos one or a unix one or anything.
61 is hex for 'a'
C:\somedir>echo 610d0a| xxd -r -p >testfile <ENTER>
check the file raw, in its hex
C:\somedir>cat testfile | xxd -p <ENTER>
610d0a
check the file in ascii or unicode
C:\somedir>cat testfile <ENTER>
a
and the following commands just prove that dos2unix and unix2dos work/are working fine.
C:\somedir>dos2unix testfile <ENTER>
testfile: done.
C:\somedir>cat testfile | xxd -p <ENTER>
610a
C:\somedir>unix2dos testfile <ENTER>
testfile: done.
C:\somedir>cat testfile | xxd -p <ENTER>
610d0a
C:\somedir>
lưu ý - trong trường hợp sử dụng phân phối * nix, hãy xem apt-get (apt-cache search dos2unix) gói thực sự (có lẽ không có gì đáng ngạc nhiên!) dos2unix (được cài đặt với apt-get install dos2unix) và bao gồm cùng với dos2unix thực thi, thực thi unix2dos. Nếu bạn thực hiện tìm kiếm apt-cache unix2dos, nó sẽ hiển thị gói dos2unix.