Date: Tue, 11 Nov 2008 20:56:41 +0100 From: =?utf-8?Q?Fr=C3=A9d=C3=A9ric_Perrin?= <frederic.perrin@resel.fr> To: freebsd-questions@freebsd.org, Aggelidis Nikos <aggelidis.news@gmail.com> Cc: Mel <fbsd.questions@rachie.is-a-geek.net> Subject: Re: Using grep to search a repository Message-ID: <86zlk6yr2e.fsf@chameau.maisel.enst-bretagne.fr> In-Reply-To: <200811111936.23400.fbsd.questions@rachie.is-a-geek.net> (Mel's message of "Tue, 11 Nov 2008 19:36:22 %2B0100") References: <30fc78250811111017l5f087dc8o52c1f1367e056ecd@mail.gmail.com> <200811111936.23400.fbsd.questions@rachie.is-a-geek.net>
next in thread | previous in thread | raw e-mail | index | archive | help
Le Mardi 11 à 19:36, Mel a écrit :
> On Tuesday 11 November 2008 19:17:28 Aggelidis Nikos wrote:
>> Hi to all the list,
>>
>> i have a project with a lot of bash scripts in a folder hierarchy.I
>> haven't wrote the project myself so many times i have to search for
>> the definition of a function. For this purpose i decided to use grep
>> {recursively}.
>> The problem is that the project is an svn repository... so grep
>> returns results from .svn and it is really messes up the outcome of
>> grep. I tried bypassing the problem using the `--exclude=file_pattern'
>> but since its use is for files not directories it doesn't work.... So
>> the questions are:
>>
>> 1) Can i bypass certain directories{i.e. '.svn' or 'log/'}, using
>> grep? {or a combination of tools + grep}
>
> man find(1), specifically -path and -exec arguments. Example:
>
> find . -type f \( \! -path '*/.svn/*' -a \! -path '*/log/*' \) \
> -exec grep foo {} +
FWIW, when doing a similar search, the command built by emacs is (a
longer version of) the following :
find . \( -path \*/.svn -o -path \*/log \) -prune -o -type f \( -name
\*.sh\* \) -exec grep -i -nH -e pattern {} /dev/null \;
Isn't "-path .svn -prune" more efficient than "! -path .svn"? I mean,
with the second one, won't find also descend into .svn folders, only to
find that all files have a path containing .svn?
--
Fred
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86zlk6yr2e.fsf>
