例:2つのファイルがあります。
入力.txt
one
two
three
four
five
出力.txt
1
2
3
4
5
これら2つのファイルをマージして、次のように別の出力ファイル(match.txtなど)をインポートしたいと思います。
one 1
two 2
three 3
...
さらに、2つの.txtファイルをランダムに混在させると、出力ファイル(match.txt)も次のように正しいデータをマージします。
three 3
two 2
five 5
...
シェルスクリプトを書くには?
ベストアンサー1
簡単にpaste
注文する:
paste -d' ' input.txt output.txt > match.txt
コンテンツmatch.txt
:
one 1
two 2
three 3
four 4
five 5
そしてミックス(通過するsort
注文する):
paste -d' ' input.txt output.txt | sort -R
出力例:
two 2
four 4
one 1
three 3
five 5