Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Preventing "no matches found:"
- X-seq: zsh-users 9129
- From: Jos Backus <jos@xxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Preventing "no matches found:"
- Date: Fri, 22 Jul 2005 19:10:31 -0700
- In-reply-to: <488030720507221714528be98c@xxxxxxxxxxxxxx>
- Mail-followup-to: zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <EC7D91E9-B014-405A-9BC0-A4BCEFB1E24A@xxxxxxx> <20050722230139.GA81842@xxxxxxxxxxxxxxxxxxx> <488030720507221714528be98c@xxxxxxxxxxxxxx>
- Reply-to: jos@xxxxxxxxxxx
On Fri, Jul 22, 2005 at 05:14:49PM -0700, John Reese wrote:
> You can turn on noglob for a single pattern by adding a (N) flag. So
> you could just do:
>
> rm ~/log/**/*.log(m+7,N)
I knew there was a flag like that but I couldn't find it offhand.
> But that doesn't really solve your problem, because if rm has no
> arguments, it'll complain. Now, my personal advice would be to not
> care, but if you do care, you could do this:
> deadlogs=(~/log/**/*.log(m+7,N))
> ((#deadlogs)) && rm $deadlogs
I used xargs so rm would never be called without arguments, avoiding this
problem. But your solution is a little more flexible, e.g. you could emit a
message depending on whether any files will be/were removed:
deadlogs=(~/log/**/*.log(m+7,N))
if (( $#deadlogs == 0 ))
then
echo "No longs removed."
else
rm $deadlogs
echo "$#deadlogs logs removed."
fi
--
Jos Backus
jos at catnook.com
Messages sorted by:
Reverse Date,
Date,
Thread,
Author