Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: How to create unnamed temporary arrays?
- X-seq: zsh-users 3631
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: How to create unnamed temporary arrays?
- Date: Mon, 19 Feb 2001 10:55:51 +0100 (MET)
- Cc: Hannu Koivisto <azure@xxxxxx>
- In-reply-to: Hannu Koivisto's message of 19 Feb 2001 11:52:40 +0200
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
Hannu Koivisto wrote:
> Greetings,
>
> I'm currently using something like this to list the base names of
> files in /usr/local/etc/packages/ directory, each name on its own
> line:
>
> echo ${(F)$(echo /usr/local/etc/packages/*(.:t:r))}
>
> This has the obvious problem that it doesn't work if filenames have
> spaces in them. I just couldn't figure out any way to do something
> corresponding to:
>
> kala=(/usr/local/etc/packages/*(.:t:r))
> echo ${(F)kala}
>
> without creating that temporary array variable. Not that this
> really matters in this case, but I've faced situations earlier
> where avoiding the temporary name might have been more convenient
> and now I finally have a simple enough example to demonstrate it.
>
> So, is there a way? I'm using zsh versions 3.1.9-dev-6 and
> 3.1.9-dev-8 from Debian GNU/Linux testing/unstable and stable,
> respectively.
If I got that right and you really only want those filenames one per
line, you can just use:
print -l /usr/local/etc/packages/*(.:t:r)
(the -l option to print makes it print the argument one per line).
Bye
Sven
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author