再帰的にコピーするサブディレクトリと、ファイルを含む大きなディレクトリがあります。
cp
最小のファイルが最初にコピーされるようにファイルサイズ順にコピー操作を実行する必要があることを知らせる方法はありますか?
ベストアンサー1
次はrsync
。
まず、小さなファイルのみを転送してください。
rsync -a --max-size=10m srcdir dstdir
その後、残りのファイルを転送します。以前に送信された小さなファイルは、変更しない限り再コピーされません。
rsync -a srcdir dstdir
~からman 1 rsync
--max-size=SIZE
This tells rsync to avoid transferring any file that is larger
than the specified SIZE. The SIZE value can be suffixed with a
string to indicate a size multiplier, and may be a fractional
value (e.g. "--max-size=1.5m").
This option is a transfer rule, not an exclude, so it doesn’t
affect the data that goes into the file-lists, and thus it
doesn’t affect deletions. It just limits the files that the
receiver requests to be transferred.
The suffixes are as follows: "K" (or "KiB") is a kibibyte
(1024), "M" (or "MiB") is a mebibyte (1024*1024), and "G" (or
"GiB") is a gibibyte (1024*1024*1024). If you want the multi‐
plier to be 1000 instead of 1024, use "KB", "MB", or "GB".
(Note: lower-case is also accepted for all values.) Finally, if
the suffix ends in either "+1" or "-1", the value will be offset
by one byte in the indicated direction.
Examples: --max-size=1.5mb-1 is 1499999 bytes, and
--max-size=2g+1 is 2147483649 bytes.
もちろん、ファイルごとの転送順序が最も小さいものから最大のものの順に厳密に決まったわけではありませんが、これがおそらくあなたの要件に適合する最も簡単な解決策であると思います。