From owner-freebsd-questions@FreeBSD.ORG Tue Nov 11 19:56:53 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D86851065679 for ; Tue, 11 Nov 2008 19:56:53 +0000 (UTC) (envelope-from frederic.perrin@resel.fr) Received: from maisel-gw.enst-bretagne.fr (maisel-gw.enst-bretagne.fr [192.44.76.8]) by mx1.freebsd.org (Postfix) with ESMTP id 7B8AB8FC22 for ; Tue, 11 Nov 2008 19:56:53 +0000 (UTC) (envelope-from frederic.perrin@resel.fr) Received: from localhost (localhost [127.0.0.1]) by maisel-gw.enst-bretagne.fr (Postfix) with ESMTP id 1BBB719CF2; Tue, 11 Nov 2008 20:56:52 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at resel.fr Received: from maisel-gw.enst-bretagne.fr ([127.0.0.1]) by localhost (mercure.adm.maisel.enst-bretagne.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZVW+p6GJUWRA; Tue, 11 Nov 2008 20:56:46 +0100 (CET) Received: from chameau.maisel.enst-bretagne.fr (chameau.maisel.enst-bretagne.fr [172.22.209.241]) (Authenticated sender: fperrin) by maisel-gw.enst-bretagne.fr (Postfix) with ESMTP id C3E9719D47; Tue, 11 Nov 2008 20:56:45 +0100 (CET) Received: by chameau.maisel.enst-bretagne.fr (Postfix, from userid 1001) id 6220EB844; Tue, 11 Nov 2008 20:56:41 +0100 (CET) From: =?utf-8?Q?Fr=C3=A9d=C3=A9ric_Perrin?= To: freebsd-questions@freebsd.org, Aggelidis Nikos Organization: =?utf-8?Q?R=C3=A9seau?= des =?utf-8?B?w4lsw6h2ZXM=?= References: <30fc78250811111017l5f087dc8o52c1f1367e056ecd@mail.gmail.com> <200811111936.23400.fbsd.questions@rachie.is-a-geek.net> Date: Tue, 11 Nov 2008 20:56:41 +0100 In-Reply-To: <200811111936.23400.fbsd.questions@rachie.is-a-geek.net> (Mel's message of "Tue, 11 Nov 2008 19:36:22 +0100") Message-ID: <86zlk6yr2e.fsf@chameau.maisel.enst-bretagne.fr> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: Mel Subject: Re: Using grep to search a repository X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Nov 2008 19:56:53 -0000 Le Mardi 11 =C3=A0 19:36, Mel a =C3=A9crit : > 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=3Dfile_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? --=20 Fred