LoginSignup
0
0

並列で md5sum のチェックを行うのは簡単

Posted at

ネットでググってもすぐに解答が出てこないが実は簡単なのでメモする。

md5sum -c md5sum.txt

md5sum.txt-c オプションの引数に見えるが、そうではないのがポイント。
実は、標準入力から md5sum.txt をコマンドに渡すことも可能だ。

cat md5sum.txt | md5sum -c

これさえ理解すればあとは簡単である。md5sum.txt を分割して標準入力から渡してやればいい。あとは好きなUnixの並列化コマンドを使うだけである。ここでは xargs を使って -P 4 を指定した。

cat md5sum.txt | xargs -I{} -P 4 sh -c "echo \"{}\" | md5sum -c"

md5sum の計算は高速である。だから並列数を増やしてもIOがボトルネックになりやすい。IOと計算のどちらがボトルネックになっているか htop などでモニターしながら調節すればいいと思う。

この記事は以上です。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0