共通したファイルをハードリンクにするスクリプト
概要
- --path(デフォルト)だと指定されたディレクトリからのパスが同じでかつファイルデータが同じであればハードリンク化する。
- --hashだと完全にファイルデータのみで比較して、同じデータであればハードリンク化する。
- 全部の同じデータがハードリンク化されるので--pathより小容量になる
pdumpfsみたいなディレクトリ構成のものをドライブを越えて
コピーするとハードリンクでなくなるのでそれを元に戻す時に使える。
後は単純に重複したファイル同士をハードリンク化して
容量をダイエットしたい時とか。
ただ注意としては、特に--hashでやると
意図しないファイルまでハードリンク化されて
AだけいじったのにBってファイルまで変更されてるみたいなことが起きるかも。
純粋にバックアップ用途で、ファイルはいじらないというのであれば--hashでもいいかもしれない。
help
NAME
weavel - unlink and link duplicated filesSYNOPSIS
# Let duplicated files (in same head path) have same inodes.
$ weavel --path dir1/ dir2/
# Let duplicated files (in same file data) have same inodes.
$ weavel --hash dir1/ dir2/ dir3/OPTIONS
-h, --help
Show this help.-l, --follow-symlinks
Follow symbolic links.-v, --verbose
Show verbose output.--path
Find two same files by two directories' paths. This is default. See
--hash for another strategy to find same files.--hash
Find two or more same files by file data with MD5.AUTHOR
tyru
最新/最古のatime/mtime/ctimeを調べるスクリプト
概要
シェルスクリプトでできる範囲かと思ったら以外とやり方わからなかったのでスクリプト作ってみた。
普通になんかのオプション見失ってるだけかもしれない。知ってる方教えてください。
最新のmtimeを調べるには
$ perl top-timestamp.pl --latest --mtime
とかやる。
あと
$ perl top-timestamp.pl --oldest --latest --mtime --ctime --atime
とかやれば最新/最古のmtime/ctime/atime全部調べる。それSYNOPSISに書けよ。*1
help
NAME
top-timestamp.pl - Get latest/oldest timestamp (atime, mtime, ctime)SYNOPSIS
$ perl top-timestamp.pl OPTIONS dir1 [dir2 ...]OPTIONS
-h, --help
Show this help.-f, --date-format {format}
Specify date format to be output.if specified, the result is the same as when POSIX's strftime() is
used (top-timestamp.pl is using Time::Piece).if not specified, the output string is the same as localtime() or
gmitime() (string in scalar context).--latest
Find and show latest timestamps. --atime, --mtime, --ctime to
specify timestamps to find.--oldest
Find and show oldest timestamps. --atime, --mtime, --ctime to
specify timestamps to find.--atime
Find and show atime.--mtime
Find and show atime.--ctime
Find and show atime.-d, --directory
Check timestamps for also directories.-l, --follow-symlinks
Follow symlinks.-v, --verbose
For debug.AUTHOR
tyru
*1:かきわすれた