Oh come on...
Shell syntax's are great. They're in the same league as the APL syntax.
Both leave obfuscated C for dead.
Mark ;-0
On Wed, 2006-10-18 at 14:32 +1000, Martin Pool wrote:
> On 17 Oct 2006, Sonia Hamilton <[EMAIL PROTECTED]> wrote:
> > I've written a small script that archives email - it works, but I was
> > wondering if there's any better way to write it (apart from using
> > another language).
> >
> > The script is:
> >
> > > for i in z_bak:7 root:14 y_spam_definite:56 ; do
> > > mydir=${i%:*}
> > > mydays=${i#*:}
> >
> > $mydir is the directory to cleanup, $mydays is the # of days I want to
> > keep email. Is there any better way of writing the for loop to go thru
> > the 2 sets of values?
>
> Using associative arrays in zsh (or ksh or maybe bash?) you can write
>
> typeset -A to_archive
> to_archive=(z_bak 7 root 14 y_spam_definite 56)
> for mydir in ${(k)to_archive}
> do
> mydays=$to_archive[$mydir]
>
> But I've actually never used them before doing this, and I have to say
> the ${(k)to_archive} is beyond my current tolerance for shell wierdness.
>
> --
> Martin
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html