[NTLUG:Discuss] Re: Is there a command line utility which will report directory statistics?
Terry
trryhend at gmail.com
Fri Jan 20 14:37:56 CST 2006
On 1/20/06, Leroy Tennison <leroy_tennison at prodigy.net> wrote:
> Graham Wilson wrote:
>
> >On Thu, Jan 19, 2006 at 06:20:47AM -0600, Leroy Tennison wrote:
> >
> >
> >>Such things as number of files,
> >>
> >>
> >
> >find $dir -type f | wc -l
> >
> >
> >
> >>number of subdirectories,
> >>
> >>
> >
> >find $dir -type d | wc -l
> >
> >
> >
> >>size?
> >>
> >>
> >
> >du
> >
> >
> >
> Thank you, that's exactly what I needed and would have never found by
> searching. A couple of questions:
>
> Where is $dir documented? I thought it was a reference to a BASH shell
> variable but couldn't find either 'dir' or 'DIR' using "set | less".
> Googling and trying Yahoo proved futile because both interpret the $
> somehow.
>
> Second, I take it that 'du' reports only in blocks rather than actual
> aggregates of sizes even if the '-b' switch is used, correct? The
> reason I ask is that I'm looking for an equivalent of what the Evil
> Empire does when it calculates directory sizes.
>
I will try to put this into terms that might be more understandable to you.
(Someone please correct me if I get any of this wrong.)
du by default reports in kilobytes
The switch -b will report in bytes
du [filename] will report the amount of disk space that is
consumed in storing a single file, [filename], in 1k increments [on
your hard disk drive].
du -b [filename] will report the amount of disk space that is
consumed in storing [filename] in bytes [on your hard disk drive].
du [filename] gives report in 1k increments [default]
du -k [filename] gives report in 1k increments
du -b [filename] gives report in 1byte increments
du -h [filename] gives report in megabytes or kilobytes or
gigabytes [rounded off], (as is most appropriate), and the report will
look something like this:
du -b [very-large-file] 16504180736
du -h [very-large-file] 16G
or, ... (here is a du report on a 15megabyte file)
du 05.pdf 14468 05.pdf
du -k 05.pdf 14468 05.pdf
du -b 05.pdf 14815232 05.pdf
du -h 05.pdf 15M 05.pdf
du will report to you the amount of disk space that is consumed by a
file, or directory full of files, or set of directories full of files,
as per your choosing. (-s gives summary).
> Again, thanks for the help.
>
>
>
> _______________________________________________
> https://ntlug.org/mailman/listinfo/discuss
>
--
<><
More information about the Discuss
mailing list