2009-10-29 4 views
79

約2つのフォルダがあります。 150のJavaプロパティファイル。コンテンツ内に多数のファイルがある2つのフォルダを比較します。

シェルスクリプトでは、両方のフォルダを比較して、どちらかに新しいプロパティファイルがあるかどうか、およびプロパティファイルの違いを確認する方法を教えてください。

出力はレポート形式である必要があります。

答えて

152

新しい/不足しているファイルの概要を取得するには、どのファイルを異なる環境:Unixにおける

diff -arq folder1 folder2 
+5

'a'はすべてのファイルをテキストとして扱います、' r'は再帰的に検索されるサブディレクトリです。 'q'はファイルが異なるときにのみ '短時間'を報告します。 – MackM

+0

@reko_tは' Java' –

23

diff -rファイルが追加または削除されたか、変更されたファイルが変更されたかの両方が表示されます。

-1

diffコマンドは、ファイル(すべてのタイプ)の違いを見つけるために使用されます。ディレクトリもファイルの一種であるため、diffコマンドを使うことで2つのディレクトリの違いを簡単に把握できます。その他のオプションについては、あなたのUnixボックスにのman diffを使用してください。

-b    Ignores trailing blanks (spaces and tabs) 
       and treats other strings of blanks as 
       equivalent. 

-i    Ignores the case of letters. For example, 
       `A' will compare equal to `a'. 
-t    Expands <TAB> characters in output lines. 
       Normal or -c output adds character(s) to the 
       front of each line that may adversely affect 
       the indentation of the original source lines 
       and make the output lines difficult to 
       interpret. This option will preserve the 
       original source's indentation. 

-w    Ignores all blanks (<SPACE> and <TAB> char- 
       acters) and treats all other strings of 
       blanks as equivalent. For example, 
       `if (a == b)' will compare equal to 
       `if(a==b)'. 

などあります。

1

私はnodejsのアプリで

diff -rqyl folder1 folder2 --exclude=node_modules 

を使用。

関連する問題