답변:
Cygwin에 Cygwin 및 Dos2unix 설치
find . -type f -exec dos2unix {} \;
-maxdepth 1하위 디렉토리를 거치지 않도록 할 수도 있습니다.
Windows에서 cygwin32 (또는 이와 유사한) 대신 git bash 를 설치할 수 있습니다 . 그것은 여러 유닉스 같은 명령 (예를 들어, 함께 제공 find, dos2unix에서, 등) bash에뮬레이션 모드. 일단 설치되면 Windows에서 Unix 파일로 파일을 쉽게 변환 할 수 있습니다.
src 라는 폴더 트리에 파일 (접미사 .java로 끝나는 파일 )이 있고 그 끝을 Windows에서 Unix로 변환 한다고 가정 해 봅시다 .
find . -name "*.java" -exec dos2unix {} \;.그리고 그게 다야!
dos2unix와 unix2dos를 사용하는 당신의 대답은 훌륭합니다.
귀하의 답변을 기반으로 한 다른 방법이 있습니다.
재미있게도 Gnuwin32를 사용할 수 있지만 명령이있는 Gnuwin32 패키지는 Cygutils http://gnuwin32.sourceforge.net/packages/cygutils.htm 이므로 C : \ Program Files에서 unix2dos.exe 및 dos2unix.exe를 얻습니다. .... \ GnuWin32 \ bin과 PATH에 있습니다.
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>
그리고 당신의 % f가 원하는 것을 할 것인지 테스트하려면 echo 또는 @ECHO를 사용하십시오. 예
를 들어 (*)에서 % f를 위해 @ECHO unix2dos % f
xxd를 사용하여 파일을 작성하고 파일이 변환되었는지 테스트 할 수 있습니다. Windows 용 xxd는 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>
참고-* nix 배포판을 사용하는 경우 apt-get (apt-cache search dos2unix)을보고 패키지가 실제로 (아마도 놀랍지 않게!) dos2unix (apt-get install dos2unix와 함께 설치됨)이며 dos2unix와 함께 포함됩니다. 실행 파일, unix2dos 실행 파일 unix2dos 검색을 apt-cache하면 dos2unix 패키지가 표시됩니다.