coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: adding a feature to the du util


From: Noam Yizraeli
Subject: Re: adding a feature to the du util
Date: Wed, 13 Jan 2021 17:08:16 +0200

Ok, thanks for the clarification.
If you'll have any need for adding features to the core utils repo I'd love
to hear about it 😁

Best Regards,
Noam.

On Mon, Jan 11, 2021, 19:39 Bernhard Voelker <mail@bernhard-voelker.de>
wrote:

> On 12/22/20 11:02 PM, Noam Yizraeli wrote:
> > I would like to add an option to view du output from du -sh for a certain
> > directory with also including hidden files and dirs.
>
> I'm not sure what exactly you mean, and you didn't provide an example.
> 'du' already includes the count for "hidden" files.
>
> My guess is that you mean a call like:
>
>   $ du -sh *
>
> The point is that 'du' only processes the entries explicitly
> passed to it.  And it doesn't do the expansion of '*' itself;
> in fact, it doesn't see the '*' at all.  Instead, the calling
> shell does the expansion.  There's nothing we can do about in 'du'.
> Example:
>
>   $ ls -alog
>   total 956
>   drwxr-xr-x  4   4096 Jan 11 18:28 .
>   drwxrwxrwt 30 663552 Jan 11 18:27 ..
>   -rw-r--r--  1   1235 Aug 14  2018 .profile
>   drwx------  2   4096 Aug 11 22:45 .ssh
>   drwxr-x--- 16   4096 Dec 18 19:07 dir1
>   -rwxr-xr-x  1 291352 Jan 11 18:28 file1
>
>   $ du -sh *
>   63M   dir1
>   288K  file1
>
> To see how the shell calls 'du', you could use the 'echo' command
> in front of it:
>
>   $ echo du -sh *
>   du -sh dir1 file1
>
> So 'du' is called with those 2 file names only, but not the hidden ones.
> This is because the shell globbing doesn't expand '*' to hidden files
> per default.
> E.g. in 'bash' as the calling shell, you could change this by the 'dotglob'
> option via `shopt -s dotglob`.
>
>   $ shopt -s dotglob
>   $ echo du -sh *
>   du -sh .profile .ssh dir1 file1
>
> Is that what you mean?
>
> Have a nice day,
> Berny
>
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]