awk help needed

Giles Orr gilesorr-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Tue Jul 21 02:11:14 UTC 2009


2009/7/19 William Park <opengeometry-FFYn/CNdgSA at public.gmane.org>:
> On Sun, Jul 19, 2009 at 12:27:22PM -0400, Giles Orr wrote:
>> I would love to use "du" because initially it seems like precisely the
>> right tool ... but I want only the sum of the sizes of the files in
>> the current directory, and "du" is by default recursive (which also
>> makes it painfully slow to return, not a good thing for something
>> incorporated into a Bash prompt).  If it's possible to stop "du" from
>> recursing, I'll use it immediately - but that looks difficult to
>> impossible.  Any thoughts?
>
> 1.  (find -type f -maxdepth 1 -mindepth 1 -printf '%s+'; echo 0) | bc
> 2.  $(( $(find -type f -maxdepth 1 -mindepth 1 -printf '%s+') 0 ))
>
> You can use '%k' and '%b' to get disk space in 1024 and 512 bytes.

Wow, thanks: that's a thing of beauty.

-- 
Giles
http://www.gilesorr.com/
gilesorr-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list