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

Re: Suppressing failed glob patterns



On Thu, Dec 04, 2008 at 04:30:58PM -0500, Benjamin R. Haskell wrote:
> On Thu, 4 Dec 2008, Thorsten Kampe wrote:
>
>> Yes, I know about that. And that's what I've been using until now. But 
>> it's also exactly what I not what. I don't what to give the command an 
>> empty pattern. Compare:
>>
>> % rm non-existing-file.*
>> zsh: no matches found: non-existing-file.*
>>
>> % rm non-existing-file.*(N)
>> rm: missing operand
>> Try `rm --help' for more information.
>>
>> I just want rm not to be executed (like it's the default) but without
>> the error (which is fine when I do it interactively but not in a
>> script).
>>
>> Thorsten
>
>
> You want both of the things suggested in this thread ('-f' and '(N)'):
>
> # original problem
> $ rm non-existing-file.*
> zsh: no matches found: non-existing-file.*
>
> # '-f' doesn't solve 'no matches'
> $ rm -f non-existing-file.*
> zsh: no matches found: non-existing-file.*
>
> # '(N)' doesn't solve the 'missing operand'
> $ rm non-existing-file.*(N)
> rm: missing operand
> Try `rm --help' for more information.
>
> # '(N)' solves one, '-f' solves the other
> $ rm -f non-existing-file.*(N)
> $
[...]

But

rm -f file1.*(N) file2.*(N)

would silently remove file1.xxx while there's no file2.* file
which the OP didn't want (he wanted rm not to be run if any one
pattern doesn't match any file).

-- 
Stéphane



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