Subject: Re: bug#49381: v.8.32 – du(1) | Calculating the total size of files | One file covered instead of all

From: Glenn Golden <[email-masked]>
Date: Sun, 4 Jul 2021 08:35:12 -0600

Ricky Tigg <[email-masked]> [2021-07-04 16:54:04 +0300]:
> *OS:* Fedora; Tested in Bash v.5.1.
> 
> Hello. Task: Printing total size of files *alone*.
> To reproduce:
> 
> $ stat -c '%i %h %s %n %F' k l
> 4198568 2 34 k regular file
> 4198568 2 34 l regular file
> 
> $ find . -type f
> ./k
> ./l
> 
> Those  'du' commands cover only one file instead of all files.
> 
> $ find . -type f -exec du -acb {} +
> 34 ./k
> 34 total
> 
> $ find . -type f -print0 | du --files0-from=- -cb
> 34 ./k
> 34 total
> 
> Isn't rather *68* expected?

You probably want to specify --count-links if you want hardlinked files
(like your example k and l) to be considered by du as separate files:

    $ echo foo > k
    $ ln k l

    $ du -c k l
    4       k
    4       total

    $ du -c --count-links k l
    4       k
    4       l
    8       total