0
0

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.

find / tar の組み合わせではまったことのメモ

Posted at

やりたいこと

90日以内に更新されたすべてのファイルを tar でまとめたい。 しかし、find の結果ではちゃんと抽出されているのに、なぜかディレクトリ以下のすべてのファイルが tar の対象となってしまう。

解決策

-type f でファイルのみを対象とすること。

find . -type f -daystart -mtime -90 -print0 | tar -cvz -T - --null -f ~/archive.tar.gz

-type f を忘れると、ディレクトリが候補に入っていた場合にそのディレクトリ以下に含まれる全ファイルが対象になってしまう。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?