Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: print entire array *with* subscript?
- X-seq: zsh-users 9902
- From: Jean-Rene David <jrdavid@xxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: print entire array *with* subscript?
- Date: Fri, 10 Feb 2006 12:50:12 -0500
- In-reply-to: <200602101756.59858.arvidjaar@xxxxxxx>
- Mail-followup-to: zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
* Andrey Borzenkov <arvidjaar@xxxxxxx>:
> but I really fail to see when it can be useful. After all to print all array
> indices (ignoring KSH_ARRAYS for the moment):
>
> {pts/0}% echo {1..$#foo}
> 1 2 3
The usefulness is a little more obvious when
printing both indices and values.
The original idea was this. Suppose I have a list
of files in an array and I want to select one to
do a command on.
files=(foo.h foo.c bar.h bar.c)
It would be nice to be able to do this:
print ${(k)files}
1 foo.h 2 foo.c 3 bar.h 4 bar.c
instead of:
for f in {1..$#files}; do
print $f ${files[$f]};
done
Not a big deal. Just asking because that's what I
thought the documentation meant.
Now that I wrote all this I realize I could just
use 'select'...
--
JR
Messages sorted by:
Reverse Date,
Date,
Thread,
Author