zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: Sven Guckes <guckes@math.fu-berlin.de>, zsh-users@math.gatech.edu
Subject: Re: lssum - summing up sizes of files
Date: Sat, 13 Jun 1998 10:06:41 -0700	[thread overview]
Message-ID: <980613100641.ZM27081@candle.brasslantern.com> (raw)
In-Reply-To: <19980613181013.A4302@math.fu-berlin.de>

On Jun 13,  6:10pm, Sven Guckes wrote:
} Subject: lssum - summing up sizes of files
}
} Does anyone have a nice and small function to sum up the sizes of files?
} I just hope this isn't a standard example in the zsh manuals - yet.
} but I think it should be.  ;-)

The manual is woefully short of examples; it's almost exclusively limited
to descriptive text.

In any case, in 3.1.4 with the "stat" module loaded, you can do it with

    sumsizes() {
        local sum sizes i
	stat -A sizes +size $*
	sum=0; for i in $sizes; ((sum += i))
	print sum
    }

E.g.
	sumsizes **/*.o

Replace +size with +block if you want the actual disk block usage.

In 3.0, there's no direct way to read the size of the file into the shell.
You'd have to run "ls" and parse the output, or something.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


  reply	other threads:[~1998-06-13 17:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-06-13 16:10 Sven Guckes
1998-06-13 17:06 ` Bart Schaefer [this message]
1998-06-13 19:12   ` Sven Guckes
1998-06-13 19:33     ` adding examples to man pages Richard Coleman
1998-06-13 19:38     ` lssum - summing up sizes of files Danek Duvall
1998-06-13 21:56       ` Sven Guckes
1998-06-14  0:20         ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=980613100641.ZM27081@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=guckes@math.fu-berlin.de \
    --cc=zsh-users@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).