Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Preventing "no matches found:"

Thanks to both. I was looking for the ,N, as I've come up with a few methods to "silence" it otherwise, but I felt there was likely a more elegant manner.


On Jul 22, 2005, at 7:10 PM, Jos Backus wrote:

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)) && 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:

    if (( $#deadlogs == 0 ))
    echo "No longs removed."
    rm $deadlogs
    echo "$#deadlogs logs removed."

Jos Backus
jos at catnook.com

Messages sorted by: Reverse Date, Date, Thread, Author