Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Applying glob qualifiers to non-variable types
- X-seq: zsh-users 17398
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Matthias Vallentin <vallentin@xxxxxxxxxxxxxxxxx>
- Subject: Re: Applying glob qualifiers to non-variable types
- Date: Fri, 16 Nov 2012 20:55:15 +0100
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1353095716; bh=ojtSvU7f2daS34tqQUpOohqKkp1SH6L/+LwtQQUV5CU=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:Received:cc:In-reply-to:From:References:To:Subject:Date:Message-ID; b=EU291lQki462Kv81v3Kek1YB8RquC9YgdUsgjAcLWu5LxoC1W0ZQ2joidXY1ChvoI9FdySlLrtmol442DS6WRWx8l+eUAe0zRQK3hRTVsC2ytFraCD4nuCOCFjP7ymaGj7F2aCvsdgj2HVSaGY2FBbVJsXCKWNjyRRiboGGLxGM=
- In-reply-to: <20121116180016.GJ24247@icir.org>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20121116180016.GJ24247@icir.org>
Matthias Vallentin wrote:
> I have a scenario where a command gives similar output to find, .e.g.,
>
> ./path/to/foo.ext
> ./path/to/bar.ext
>
> I was wondering if it is possible to use glob qualifier to handle the
> output in the following way:
>
> command | print <?>:t:r
>
> where <?> would be some magic I am missing. I tried to capture STDIN in
> various ways $(</dev/stdin), $(<&0), etc., but could not find working
> solution.
You can use a while loop - something like:
command | while read file; do
print $file:t:r
done
If you're using a command that, unlike print, can't be invoked for each
file separately then you can use something like the following:
print ${^$(command)}(:t:r)
The caret is only needed if you don't set rcexpandparam.
To cope with files with spaces in their names you need to use something
like ${(f)^"$(command)"}(:t:r)
Oliver
Messages sorted by:
Reverse Date,
Date,
Thread,
Author