Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: lssum - summing up sizes of files



On Jun 13,  9:12pm, Sven Guckes wrote:
} Subject: Re: lssum - summing up sizes of files
}
} Doesn't everybody need this kind of thing every day?

I've been using unix for almost fourteen years now (gaah) and I can count
the times I've *needed* that on one hand.  There were a few more times
when I was just curious, but then "wc -c * | tail -1" seemed adequate.

} > 	stat -A sizes +size $*
} 
} Looks cool!  We have zsh-3.1.2 here - will that version work?

I think the stat module is available for 3.1.2.

} Or is are "modules" a new feature of zsh-3.1.4?

No, but they're not in 3.0.

} How do you "load" those modules, anyway?

They're either built in, or if zsh was compiled for dynamic loading, then
you use the "zmodload" command.  "zmodload" works a lot like "autoload",
but searches $MODULE_PATH for a shared library (.so) named for the module.

On Jun 13, 11:56pm, Sven Guckes wrote:
} Subject: Re: lssum - summing up sizes of files
}
} Sure, but - if the zsh has to do globbing anyway
} then why not have it looks at the files, too?

Most globbing can be done by reading the directory structure.  Looking at
the files too is much more expensive.

} As there is a GLOBBING modifier for "size"

File-statistics glob qualifiers (modifiers are qualifiers that change
the string that is returned after the glob succeeds) are used only to
eliminate a file after all the fast pattern matching on its name has
succeeded.

} there must be a nice way to extract the size of files somehow.

That's what the "stat" module is for.

An interesting alternative to the "stat" module would be a glob modifier
that replaces the file name with one of its statistics.  E.g.

echo *(D:#G)

might echo the group-ids of every file in the current directory (:#L for
the size, :#m for the mod time, etc.).  I don't plan to hold my breath
expecting someone to implement this, though.

} Would be nice if there was an easy way to get the sum
} without writing an explicit loop for this, too.

That's an awfully special special-case.  Is there some kind of general
loop replacement that you're thinking of?

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



Messages sorted by: Reverse Date, Date, Thread, Author