La tua risposta per usare dos2unix e unix2dos è eccellente.
Ecco un altro modo basato sulla tua risposta.
Puoi usare Gnuwin32 anche se stranamente il pacchetto Gnuwin32 che ha i comandi è Cygutils http://gnuwin32.sourceforge.net/packages/cygutils.htm , quindi otterrai unix2dos.exe e dos2unix.exe in C: \ Programmi .... \ GnuWin32 \ bin e con quello nel tuo PERCORSO.
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>
E per verificare se il tuo per% f farebbe quello che vuoi, quindi usa echo o @ECHO ad es.
Per% f in (*) fai @ECHO unix2dos% f
E puoi usare xxd per creare i file e testarli convertiti. xxd per Windows viene fornito con VIM C: \ Program "" 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>
nota- anche nel caso in cui usi una distro * nix, guardando apt-get (apt-cache search dos2unix) il pacchetto è effettivamente (forse non sorprende!) dos2unix (così installato con apt-get install dos2unix) e che include insieme a dos2unix eseguibile, l'eseguibile unix2dos. Se si esegue la ricerca nella cache di apt unix2dos, mostra il pacchetto dos2unix.