2つのログを1行ずつ比較し、違いと行の単語の順序が同じかどうかを示します。 [重複]

2つのログを1行ずつ比較し、違いと行の単語の順序が同じかどうかを示します。 [重複]

ツールも必要なく、実装/アルゴリズムも必要です :) サーバーに何もインストールできないため、シェルスクリプトを作成する必要があります。

f2.txt

She has 123 apples
George 18 years is old
Florin it's leaving
Michael it's not here
Peter is smiling

f1.txt

She has 132 apples
George is 18 years old
Michael it's not here
Peter is smiling
He is sleeping

希望の出力:

diff is at:
line 1 : 123 instead of 132
line 2 : 18 years is instead of is 18 years
lines missing:
He is sleeping
lines added:
line 3: Florin it's leaving

ベストアンサー1

要求された形式と正確に一致するわけではありませんが、wdiffおそらく最善の選択でしょう。

$ wdiff f1.txt f2.txt
She has [-132-] {+123+} apples
George [-is-] 18 years {+is+} old
{+Florin it's leaving+}
Michael it's not here
Peter is smiling
[-He is sleeping-]

おすすめ記事