Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

grep -r doesn't work for me

51 views
Skip to first unread message

Mickey Ferguson

unread,
Feb 22, 2008, 3:55:11 PM2/22/08
to
I'm using grep 2.5.1 (Cygwin), which is the latest version of gnu grep I can find for Windows.  I'm also including the part of the help text that explains the usage of the -r (recursive) switch:
 
  -R, -r, --recursive       equivalent to --directories=recurse
      --include=PATTERN     files that match PATTERN will be examined
      --exclude=PATTERN     files that match PATTERN will be skipped.
      --exclude-from=FILE   files that match PATTERN in FILE will be skipped.
 
My problem is that it just doesn't work for me.  (I'm using XP SP2.)  When I use the -r switch, I get a 'Not enough space' error.  I have no idea what space it's run out of - I should have plenty of memory available, and the same for disk space (if it needed it for swapping, whatever).  Any help would be greatly appreciated.

->grep --version
grep (GNU grep) 2.5.1
 
Copyright 1988, 1992-1999, 2000, 2001 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
->grep -rl --include=*.ini Change
grep: (standard input): Not enough space

I've created an alias in my command processor (4nt) language, that will go through each folder, and then execute the regular grep command "grep -s -c -m 1 [string search pattern] [file pattern]" and check to see if it returns at least one match.  If it does, it prints the current directory and then executes the full grep command "grep -H [...]" so I see the results.  This works fine, but I'd rather figure out what I'm doing wrong above with the -r switch.

->alias rgrep
global /iq if
%@execstr[grep -s -c -m 1 %$] GT 0 (echo.%+ echo %=>%=>%=> %_cwd: %+ grep -H %$)
 
->rgrep Change *.ini
 
>>> C:\WIP\VESTA\Installer\TargetFiles\Common\Demo\INIs\DemoDBs\M1:
VESTA.ini:ChangePasswordLevel=10
 
>>> C:\WIP\VESTA\Installer\TargetFiles\Common\Demo\INIs\DemoDBs\Pallas:
VESTA.ini:ChangePasswordLevel=10
 
>>> C:\WIP\VESTA\Installer\TargetFiles\Common\Demo\INIs\DemoDBs\Standard:
VESTA.ini:ChangePasswordLevel=10

Bob Proulx

unread,
Feb 23, 2008, 4:59:25 AM2/23/08
to Mickey Ferguson, help-gn...@gnu.org
Mickey Ferguson wrote:
> My problem is that it just doesn't work for me. (I'm using XP SP2.)
> When I use the -r switch, I get a 'Not enough space' error.

That does seem strange.

> ->grep -rl --include=*.ini Change
> grep: (standard input): Not enough space

First things first. You are missing a directory argument in which to
recurse. Because grep does not have any file/directory arguments to
process it defaults to reading standard input. Using -r does not make
sense with regards to standard input.

Fix this first by giving grep a directory to recurse into. When using
the -r option it is typical to use the '.' directory. Try this:

grep -rl --include=*.ini Change .

> I've created an alias in my command processor (4nt) language, that

The typical way to do this would be to use 'find'.

find . -name "*.ini" -exec grep -l Change {} +

The {} is replaced by find with a maximum list of filenames and the
'+' terminates the command.

> ... This works fine, but I'd rather figure out what I'm doing wrong


> above with the -r switch.

Admirable. Looks like it is a bug in the port to me. It doesn't give
that error in GNU grep's native GNU environment. But your results
sound as if the code is trying to recurse on stdin and failing. That
should be reported to the Cygwin folks.

Bob


Mickey Ferguson

unread,
Feb 23, 2008, 1:25:39 PM2/23/08
to gnu-ut...@moderators.isc.org
Bob, thanks for the help. You are right about the missing directory
argument. I missed that earlier. By supplying ".", it eliminated the 'Not
enough space' error. I finally got it to the point where I got it mostly
working, but I discovered one thing about the port that may be good for the
unix environment, but doesn't work for Windows: The filename pattern
matching is case sensitive. In other words, if I had a file named
"MyFile.txt" and I searched for "my*.txt" (without the quotes in both
cases), it would fail to find it, while if I searched for "My*.txt" it would
find it. I understand that in the unix world filenames are case-sensitive,
but in the Windows world they are not. Thus, file pattern matching should
not be case-sensitive for the Windows implementation.

"Bob Proulx" <b...@proulx.com> wrote in message
news:mailman.7817.120376077...@gnu.org...

Mickey Ferguson

unread,
Mar 13, 2008, 7:19:39 PM3/13/08
to gnu-ut...@moderators.isc.org
Does anyone have a solution to the file case-sensitivity problem I'm
experiencing in grep? Filenames should NOT be case-sensitive in Windows.
Is there something I can do to fix this, either with configuration or a
command-line switch or something else?

"Mickey Ferguson" <ReneeMicke...@verizon.net> wrote in message
news:mailman.7839.12038206...@gnu.org...

Bob Proulx

unread,
Mar 14, 2008, 12:54:22 AM3/14/08
to Mickey Ferguson, help-gn...@gnu.org
Most of use got two copies of your message for some reason.

Mickey Ferguson wrote:
> Does anyone have a solution to the file case-sensitivity problem I'm
> experiencing in grep?

I take it the 'find' suggestion I posted didn't work for you?

> Filenames should NOT be case-sensitive in Windows.

You would probably have better luck asking MS-Windows questions on an
MS-Windows specific mailing list. Most of us here on the GNU lists
probably won't know enough about MS-Windows to be able to answer.

It is great that the GNU utilities are ported to your platform and are
able to help you out there but of course we are primarily concerned
about GNU utilities on GNU systems. On GNU and Unix systems filenames
are case sensitive. So we just won't have your problem.

> Is there something I can do to fix this, either with configuration or a
> command-line switch or something else?

Not that I expect you to take me up on this but the best advice I can
give you is to use a GNU system.

http://www.gnu.org/links/links.html#FreeGNULinuxDistributions

You can't expect any other advice when you ask questions on a GNU
mailing list can you? :-) I mean if you were asking MS-Windows
questions on a Mac mailing list wouldn't you expect the folks there to
suggest that you use a Mac? I would. It just naturally follows.

You said in your mail to help-gnu-utils that you were using Cygwin. I
know that Cygwin has a process for handling filename case issues. The
best place to get help for your question about the Cygwin port is on
the Cygwin mailing lists.

http://cygwin.com/lists.html

Good luck!
Bob

0 new messages