我想将一个包含大量文件的目录复制到另一个目的地。我做到了
cp -r src_dir another_destination/
然后,我想确认目标目录的大小与原始目录的大小相同:
du -s src_dir
3782288 src_dir
du -s another_destination/src_dir
3502320 another_destination/src_dir
然后,我想到可能会有多个符号链接,这些符号链接后没有cp
命令,而是添加了-a
标志:
-a与-pPR选项相同。保留文件的结构和属性,但不保留目录结构。
cp -a src_dir another_destination/
但是du -s
给了我相同的结果。有趣的是,源和目标都具有相同数量的文件和目录:
tree src_dir | wc -l
4293
tree another_destination/src_dir | wc -l
4293
使用du
命令获得不同的尺寸会导致我做错什么?
答案 0 :(得分:1)
这可能有很多原因,因为您要询问使用的磁盘大小,而不是两个树中存储的字节数。
为排除至少第一个原因(最有可能的原因),我建议在两棵树上都使用du -bs
。