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

Getting rid of temporaries...



    Hi all :))

    I want to do something with a list of files, and currently I need
a temporary variable (an array). I can do the same using find, I
suppose, but I want to do it in Zsh.

    I have a directory structure containing files whose names match
the expression '*.??.jpg'. There are some images numbered with a two
digit number. There are only one-directory depth. So, with this:

    print -l /directory/*/*

    I can print all filenames. No problem with this. The problem is
that I want to strip the number and the '.jpg' suffix from the names.
If I have the filename in a parameter, I can do:

    print -l ${parameter%.??.jpg}

    and that will do. The problem is that I want to do it in all
filenames, so I must say something like:

    typeset -a array=(/directory/*/*)
    print -l ${array%.??.jpg} | uniq

    The 'uniq' is because without the number and the extension, there
are lots of duplicates (that is what the number is for ;)), and I
want to get rid of them.

    Now the question: how can I do this without using the temporary
parameter 'array' and, if possible, without 'uniq'. I think that some
arrays can be configured to store unique copies of elements, and in
fact the (t) flag (expansion flag?) can say 'unique' for those
arrays, but I don't have damned idea of how can I declare such
arrays.

    My excuses if I'm doing lots of questions (even trivial of weird
ones), but I'm on the way of seriously learning Zsh, and I'm starting
with the user friendly guide ;)) Thanks a lot for your collaboration
and help, truly :)

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/



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