Unixで貼り付けた行が誤って重複しています。

Unixで貼り付けた行が誤って重複しています。

file1次の行を含むファイルがあります。

you are searching for a four .
you are searching for a six .
you are searching for a three .
you are searching for an ace .
you are searching for an eight .
you can use empty spaces in the Tab@@ le@@ au to move multiple cards . be careful with K@@ ings in the Reserve : the only way to remove them is by playing them to a Foundation on top of a Queen .
you can use empty spaces in the Tab@@ le@@ au to move multiple cards . be careful with K@@ ings in the Reserve : the only way to remove them is by playing them to a Foundation on top of a Queen .

file2次の行で呼び出す2番目のファイルがあります

four|||Vier
six|||Se@@ chs
for|||nach
searching|||suchen
eight|||Acht
spaces|||Plätze
spaces|||Plätze spaces|||Plätze

ただし、Unixペーストでこの行をマージするコマンドを実行した後

paste file1 file2 > result

私が得た結果は次のとおりです。

you are four|||Vieror a four .
you are six|||Se@@ chsa six .
you are for|||nachfor a three .
you are searching|||suchence .
you are eight|||Achtr an eight .
you can use empty spaces in the Tab@@ le@@ au to move multiple cards . be careful with K@@ ings in the Reserve : the only way to remove them is by playing them to a Fouspaces|||Plätzeof a Queen .
you can use empty spaces in the Tab@@ le@@ au to move multiple cards . be careful with K@@ ings in the Reserve : the only way to remove them is by playing them to a Foundation on top of a Queen .     spaces|||Plätze spaces|||Plätze

私は何が起こっているのか分かりません。各ファイルのマージされた行が重複するのはなぜですか?

ベストアンサー1

file1少なくともDOSテキストファイルはあると思います。 Unixシステムで使用される場合、これらのファイルには各行の末尾に追加のキャリッジリターン文字があります。これを端末に印刷すると、このキャリッジリターン文字はカーソルを行の先頭に戻します。 2つのファイルのデータ間に挿入されたタブ文字は、カーソルをpaste右に8文字移動します。これにより、2番目のファイルのテキストがその行の内容を上書きし、誤った出力結果が表示されます。

次のツールを使用してテキストファイルを変換する必要があります。dos2unix(これにより、ファイルは通常のWindowsテキストエンコーディングからUnixなどでより一般的に使用されるエンコーディングに正しく変換されます。)

おすすめ記事