GNU bug report logs - #45432
Use both --include and --exclude at the same time

Previous Next

Package: grep;

Reported by: "Fred .Flintstone" <eldmannen <at> gmail.com>

Date: Fri, 25 Dec 2020 16:57:02 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 45432 <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: "Fred .Flintstone" <eldmannen <at> gmail.com>
Cc: 45432 <at> debbugs.gnu.org
Subject: Re: bug#45432: Use both --include and --exclude at the same time
Date: Mon, 4 Jan 2021 09:55:48 -0800
tags 45432 moreinfo
stop

On Fri, Dec 25, 2020 at 8:57 AM Fred .Flintstone <eldmannen <at> gmail.com> wrote:
> It seems --exclude does nothing when --include is used. It would be useful
> to be able to use both together, in order to do things such as recusively
> grepping files of a certain file extension while excluding certain
> directories.
>
> Example:
> $ grep --recursive --include="*.cs" --exclude="*/tests/*"

Can you provide a complete example showing a malfunction?
You've probably already read this from "info grep", but see also
the description of --exclude there:

‘--include=GLOB’
     Search only files whose name matches GLOB, using wildcard matching
     as described under ‘--exclude’.  If contradictory ‘--include’ and
     ‘--exclude’ options are given, the last matching one wins.  If no
     ‘--include’ or ‘--exclude’ options match, a file is included unless
     the first such option is ‘--include’.




This bug report was last modified 4 years and 129 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.