Mail Archives: djgpp/1997/03/09/11:25:27
On Fri, 7 Mar 1997, DJ Delorie wrote:
> > I want to search all files on the hard
> > drive for a specific character string;
> > in the root directory, and all subdirectories.
> > ALL files.
>
> If you have a version of grep built with DJGPP Version 2
> (v2gnu/grep20b.zip), the answer is *really* simple:
>
> grep "mystring" .../*
This will work, but has two drawbacks:
1) It prints an error message about every directory it
encounters.
2) If you happen to have a binary file which includes
"mystring", the ``line'' printed to the screen can garble the entire
screen.
Therefore, I suggest using the following command instead:
find / ! -type d -exec grep -q "mystring" {} ; -print
The `-q' switch caused `grep' to only report whether the file contains
the string via its exit status, rather than printing the line with
that string.
If you want to exclude executable programs, say this:
find / ! -type d -exec ! -perm 0755 grep -q "mystring" {} ; -print
`find' is part of GNU Findutils (v2gnu/find41b.zip).
- Raw text -