Why is the cat size smaller than the actual files?

I wonder what is going on here and if in fact I am concatenating the files correctly or am I missing some of them. So, I want to bundle all the files (all txt) in a folder (called de) into one txt file. Here are my two ways:

cat de/* >> de_merged_all
du -h de_merged_all
353M    de_merged_all

      

Now if I check the size of the de folder I get:

 du -h de
 383M   de

      

So why don't these numbers match?

+3


source to share


1 answer


du

measure disk usage. Because each file is rounded to a larger block by your file system, individual small files take up more memory than one combined file.

For example:



$ echo >a
$ ls -l a
-rw-r--r-- 1 user group 1 May 23 18:33 a
joe@seashell:/tmp$ du -h a
4.0K    a

      

A single byte file occupies 4KiB of disk space.

+8


source







All Articles