Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: spaces in filenames should be a crime.
Hi Ray,
On 28.03.2017 02:46, Ray Andrews wrote:
> echo $(**/*(.om[1])
I'm afraid now you are holding it wrong :-)
1. **/*(.om[1]) will be expanded and therefore lead to a list of
matching filenames
2. the $(...) part will try to execute it as a command
But this is not what you want (usually there is no command named like
the first file found not is this what you usually want to do)
I think you are after
$ echo **/*(.om[1])
or
$ print -- **/*(.om[1])
which will just do what you want.
Cheers,
M.
PS:
Maybe you can also throw an extra (N) into the game to also handle the
case you should ever execute it in empty directories:
$ mkdir /tmp/foo_bar
$ cd /tmp/foo_bar
$ print -- **/*(.Nom[1])
does print nothing instead of throwing an "zsh: no matches found:
**/*(.om[1])" error or re-printing the pattern (depending on your
settings of nomatch and nullglob)
... Plus it gives the globbing modifiers a proximity to the Cookie
Monster's "Nom nom nom" ;-)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author