Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Suppressing failed glob patterns
- X-seq: zsh-users 13546
- From: "Benjamin R. Haskell" <zsh@xxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxxxxx>
- Subject: Re: Suppressing failed glob patterns
- Date: Mon, 8 Dec 2008 18:19:38 -0500 (EST)
- In-reply-to: <gh9hs2$ano$2@xxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <gh9g43$rt5$1@xxxxxxxxxxxxx> <20081204211315.GA13079@xxxxxxxxxxxxxxxxx> <gh9hs2$ano$2@xxxxxxxxxxxxx>
[Sorry -- responded from the wrong address, and didn't get the mailing
list notice until today]
On Thu, 4 Dec 2008, Thorsten Kampe wrote:
rm was of course only an example. You can substitute ls or print or
whatever to see what I mean.
Thorsten
You might also be interested in the '--no-run-if-empty' flag to 'xargs'.
pros: doesn't depend on nullglob setting, shell portability (e.g.
non-Zsh), more general
cons: more complex, depends on 'find' and 'xargs'
(Probably not the best solution, but it can't hurt to know.)
Examples:
find -maxdepth 1 -name 'might-not-exist.*' -print0 \
| xargs -iZ -0 --no-run-if-empty rm Z
find -maxdepth 1 -name 'might-not-exist.*' -print0 \
| xargs -iZ -0 --no-run-if-empty ls -l Z
find -maxdepth 1 -name 'might-not-exist.*' -print0 \
| xargs -iZ -0 --no-run-if-empty echo Z
# Unrelated to the current problem, but somewhere I found it useful:
# renice Audacious if it's running
pgrep audacious | xargs --no-run-if-empty sudo renice -5
Best,
Ben
Messages sorted by:
Reverse Date,
Date,
Thread,
Author