awk help needed

Chris F.A. Johnson cfaj-uVmiyxGBW52XDw4h08c5KA at public.gmane.org
Tue Jul 21 02:44:55 UTC 2009


On Mon, 20 Jul 2009, Giles Orr wrote:

> 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.

     Not if you use it anywhere but Linux. The -printf operand is
     specific to the GNU version of find.

-- 
    Chris F.A. Johnson                      <http://cfaj.freeshell.org>
    ===================================================================
    Author:
    Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)


More information about the Legacy mailing list