GNU bug report logs -
#58134
grep for windows Include GLOB pattern with double star doesn't seem to work
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 58134 in the body.
You can then email your comments to 58134 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-grep <at> gnu.org
:
bug#58134
; Package
grep
.
(Wed, 28 Sep 2022 08:45:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Alex Benoit <Alexandre.Benoit <at> microsoft.com>
:
New bug report received and forwarded. Copy sent to
bug-grep <at> gnu.org
.
(Wed, 28 Sep 2022 08:45:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hello,
I was using grep for Windows version 3.5.
I was trying to pattern match files.
At first, I thought I could put a regex as the file pattern in the command, but that didn't seem to work.
Then I looked at the --include option.
I tried
grep -l --include="**/*.xml" foo .
grep -l --include="**\*.xml" foo .
grep -l --include="**\\*.xml" foo .
Adding the recursive -r didn't help either.
However, this worked:
grep -rl --include="*.xml" foo .
Is the double star supported on Windows? What is the proper way to do it?
All the best,
Alex
[Message part 2 (text/html, inline)]
Reply sent
to
Paul Eggert <eggert <at> cs.ucla.edu>
:
You have taken responsibility.
(Wed, 28 Sep 2022 17:08:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Alex Benoit <Alexandre.Benoit <at> microsoft.com>
:
bug acknowledged by developer.
(Wed, 28 Sep 2022 17:08:02 GMT)
Full text and
rfc822 format available.
Message #10 received at 58134-done <at> debbugs.gnu.org (full text, mbox):
On 9/27/22 16:19, Alex Benoit via Bug reports for GNU grep wrote:
> However, this worked:
> grep -rl --include="*.xml" foo .
>
> Is the double star supported on Windows?
Yes and no. It's a POSIX glob, which means "**" is equivalent to "*",
and that's what's supported. Whether it's MS-Windows shouldn't matter.
> What is the proper way to do it?
Looks like you found it already.
Information forwarded
to
bug-grep <at> gnu.org
:
bug#58134
; Package
grep
.
(Wed, 28 Sep 2022 17:43:01 GMT)
Full text and
rfc822 format available.
Message #13 received at 58134-done <at> debbugs.gnu.org (full text, mbox):
On 9/28/22 10:29, Alex Benoit wrote:
> For instance, if I run the grep command from /, and I have the files:
> /a/b/folder/file.xml
> /a/b/file2.xml
> /a/folder/file3.xml
> /folder/file4.xml
>
> I want to match the file.xml, file3.xml and file4.xml, but not file2.xml, because it is not under a folder named "folder".
For that, you should use 'find' as a front end for 'grep'. It's the
usual software tools philosophy.
Information forwarded
to
bug-grep <at> gnu.org
:
bug#58134
; Package
grep
.
(Wed, 28 Sep 2022 18:35:03 GMT)
Full text and
rfc822 format available.
Message #16 received at 58134-done <at> debbugs.gnu.org (full text, mbox):
Thanks Paul, looks like the syntax reference I was using was not the right one.
What I'm really trying to do is a bit more complex and I cannot figure out if it's just not a supported feature of grep or if I'm not able to come up with the right syntax for it.
I am trying to make an include filter which will match any xml file that is in a folder with a specific name, no matter how deep that folder is.
For instance, if I run the grep command from /, and I have the files:
/a/b/folder/file.xml
/a/b/file2.xml
/a/folder/file3.xml
/folder/file4.xml
I want to match the file.xml, file3.xml and file4.xml, but not file2.xml, because it is not under a folder named "folder".
The command I would imagine would look something like:
grep -l --include="*/folder/*.xml" pattern .
I tried a couple different ways to write this and nothing worked, I wonder if grep just does not support this feature.
Note that I'm using the grep for Windows, so I don't have the typical linux tools or shell expansion tricks I can use, I'm trying to do this all in grep.
-----Original Message-----
From: Paul Eggert <eggert <at> cs.ucla.edu>
Sent: Wednesday, September 28, 2022 10:07 AM
To: Alex Benoit <Alexandre.Benoit <at> microsoft.com>
Cc: 58134-done <at> debbugs.gnu.org
Subject: [EXTERNAL] Re: bug#58134: grep for windows Include GLOB pattern with double star doesn't seem to work
On 9/27/22 16:19, Alex Benoit via Bug reports for GNU grep wrote:
> However, this worked:
> grep -rl --include="*.xml" foo .
>
> Is the double star supported on Windows?
Yes and no. It's a POSIX glob, which means "**" is equivalent to "*",
and that's what's supported. Whether it's MS-Windows shouldn't matter.
> What is the proper way to do it?
Looks like you found it already.
Information forwarded
to
bug-grep <at> gnu.org
:
bug#58134
; Package
grep
.
(Wed, 28 Sep 2022 18:35:03 GMT)
Full text and
rfc822 format available.
Message #19 received at 58134-done <at> debbugs.gnu.org (full text, mbox):
I see, this is not very easy to do on the Windows side of things, so grep has a very basic pattern matching capability for files. Thanks for the help, I'll find something that works. Was just wondering if I missed anything.
-----Original Message-----
From: Paul Eggert <eggert <at> cs.ucla.edu>
Sent: Wednesday, September 28, 2022 10:42 AM
To: Alex Benoit <Alexandre.Benoit <at> microsoft.com>
Cc: 58134-done <at> debbugs.gnu.org
Subject: Re: [EXTERNAL] Re: bug#58134: grep for windows Include GLOB pattern with double star doesn't seem to work
[You don't often get email from eggert <at> cs.ucla.edu. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
On 9/28/22 10:29, Alex Benoit wrote:
> For instance, if I run the grep command from /, and I have the files:
> /a/b/folder/file.xml
> /a/b/file2.xml
> /a/folder/file3.xml
> /folder/file4.xml
>
> I want to match the file.xml, file3.xml and file4.xml, but not file2.xml, because it is not under a folder named "folder".
For that, you should use 'find' as a front end for 'grep'. It's the
usual software tools philosophy.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 27 Oct 2022 11:24:09 GMT)
Full text and
rfc822 format available.
This bug report was last modified 2 years and 236 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.