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

Re: printing arrays and index



On Sat, 23 Jul 2005 04:59:15 +0000,  wrote:

>On Jul 22,  7:08pm, zzapper wrote:
>} Subject: printing arrays and index
>}
>} I'm using
>} 
>} print -C 1 $filessubject
>
>I was sort of puzzled by why that was suggested.  "print -l" (that's a
>lowercase L, not a one) has the same effect, and works in a lot more
>versions of zsh (the -C option is a very recent addition).
> 
>} I know want to precede each array entry with it's index number 1,2,3, etc
>} 
>} how do?
>
>The most obvious way is:
>
>	print -l $filessubject | cat -n
>
>But something like this works too:
>
>	i=0 eval print -l '$((++i))\ '${(q)^filessubject}
>
>If you use 'setopt ksharrays' then change that to $((i++)).
Thx JWTDO
-- 
zzapper
vim -c ":%s%s*%Cyrnfr)fcbafbe[Oenz(Zbbyranne%|:%s)[[()])-)Ig|norm Vg?"
http://www.rayninfo.co.uk/tips/ vim, zsh & success tips



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