2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ディレクトリ丸ごとの md5sum を取り変更を検知する

Posted at

tar と組み合わせるとハッシュ計算が1回ですむ。
以下 GNU/Linux 環境で確認。

$ tar -cPf - ./dir | md5sum -b
4a6aca1054a4730c8a86029a5788641f *-

チェックサムファイルを作っておけば変更があったかどうかがわかる

$ tar -cPf - ./foobar | md5sum -b | tee dir_checksum
5745affb9fb7e37875bf48c9c7e524c8 *-
$ tar -cPf - ./foobar | md5sum -c ./dir_checksum
-: OK
$ touch foobar/NewFile
$ tar -cPf - ./foobar | md5sum -c ./dir_checksum
-: FAILED
md5sum: WARNING: 1 computed checksum did NOT match
2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?