How to know total number of bytes of a directory
Andy Greenwood
greenwood.andy at gmail.com
Mon Dec 17 06:31:31 PST 2007
DAve wrote:
> Andy Greenwood wrote:
>
>> DSA - JCR wrote:
>>
>>> Hi all
>>>
>>> I would like to know the total number of bytes of a directory and its
>>> related subdirs, occupied by the files inside it. I haven't found any
>>> command for knowning it.
>>>
>>>
>> # du -s /etc
>> 17008 /etc
>>
>> You need read privs to all the subdirectories, otherwise you'll get
>> permission errors and it'll skip those. Note that this displays usage in
>> 512-byte blocks, not bytes, but you should be able to figure it out from
>> there.
>>
>
> -h provides human readable output.
> du -sh /etc
> 3.8M /etc
>
> DAve
>
>
Ahh, I had forgotten about -h. I ususally use du -s * | sort -rn | head
to find the biggest files/directories in a given directory, and if you
use -h, you'll get stuff out of order, since 3.8M will come after 4.2K
in a reversed numerical sort.
More information about the freebsd-questions
mailing list