Skip to content

[Solved][Linux] Use “Du” Command to Calculate the Size of Copied File but Is Different From Source File

Last Updated on 2022-04-20 by Clay

Problem

After using cp or rsync commands to copy the files, in order to make sure that there is no problem during the copying process, we may use the du command to check the size of the file.

But today, I ran into a problem where my copied file size was different from the source file.


Solution

But it does not necessarily mean that something went wrong with the copy process. The default computation of the du command is count the size of the block (disk usage). The unit size of the block is not certain, and even if only a part of the block is used, it will be calculated as a whole block, which will make the calculation more inaccurate.

At this time, we can add the --apparent-size parameter to let the du command calculate the actual size of the file.

There should be other methods that can be compared, and they will be recorded together when there is a real need.


References


Read More

Tags:

Leave a ReplyCancel reply

Exit mobile version