回答:
CygwinにCygwinおよびDos2unixをインストールしました
find . -type f -exec dos2unix {} \;
-maxdepth 1
、それはサブディレクトリを通過しないように
Windowsでは、cygwin32(または同様の)の代わりにgit bashをインストールできます。これは、いくつかのUNIXライクなコマンド(例えば、付属していますfind
、dos2unix
で、など、)bash
エミュレーションモード。インストールが完了すると、WindowsからUnixファイルエンドへのファイル変換が簡単になります。
srcというフォルダツリーにファイル(接尾辞.javaで終わる)があり、WindowsからUnixのファイル名に変換したいとします。
find . -name "*.java" -exec dos2unix {} \;
。以上です!
dos2unixとunix2dosを使用するあなたの答えは素晴らしいです。
答えに基づいた別の方法を次に示します。
コマンドを含むGnuwin32パッケージがCygutils http://gnuwin32.sourceforge.net/packages/cygutils.htmである ので、おもしろいことにGnuwin32を使用できます。したがって、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>
そして、あなたのfor%fがあなたが望むことをするかどうかをテストするには、echoまたは@ECHOを使用します。例えば
、%f in(*)do @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実行可能ファイル。apt-cache search unix2dosを実行すると、dos2unixパッケージが表示されます。