[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Finding shallowest instance of $foo in a given structure
From: |
James Youngman |
Subject: |
Re: Finding shallowest instance of $foo in a given structure |
Date: |
Thu, 20 Mar 2008 09:53:56 +0000 |
On Thu, Mar 20, 2008 at 4:59 AM, RB <address@hidden> wrote:
> I'm assuming the Texinfo page would need to be a little more
> explanatory and should stylistically fit with section 8 or 9; is that
> the case?
Yes. I'd be rather in favour of 9, "Worked Examples".
>
> Following is a patch against find.1 from findutils-4.3.13:
>
> --- find.1.orig 2008-03-19 22:22:50.240612504 -0600
> +++ find.1 2008-03-19 22:56:23.749388656 -0600
> @@ -1903,6 +1903,22 @@
> this is the default anyway, but the parentheses help to show
> what is going on.
>
> +.P
> +.nf
> +.B find repo/ \e( \-exec [ \-d {}/.svn ] \e\; \-o \-exec [ \-d
> {}/.git ] \e\; \e) \-print \-prune
> +
> +.fi
> +Search for the roots of specific SCM repositories in an efficient
> +manner.
It might help the reader to visualise what's going on if we mention
what the approximate arrangement of the tree being searched is.
> [...] As opposed to the prior example, the parentheses play
> +a critical role in combination with
> +.B \-prune
> +to prevent descent into directories that have already been
> +discovered. A more general way to express this behavior is
> +"Find the shallowest instances of repeated leaf nodes in a
> +given tree."
> This example was derived from a need to maintain
> +source synchronization with multiple projects that used
> +varying SCM tools and tree management ideologies.
Not sure that last sentence adds much, even though I asked you to
indicate the motivation.
On the subject of the command itself, it's worth considering using
just one -exec per directory:
find repo/ \( -exec test -d {}/.svn -o -d {}/.git -o -d {}/CVS \; \)
-print -prune
...or descending one level further and snipping the leaf name off with -printf:
find repo/ -type d \( -name .svn -o -name .git -o -name CVS \) -printf
"%h\n" -prune
- Finding shallowest instance of $foo in a given structure, RB, 2008/03/18
- Re: Finding shallowest instance of $foo in a given structure, Bob Proulx, 2008/03/19
- Re: Finding shallowest instance of $foo in a given structure, RB, 2008/03/19
- Re: Finding shallowest instance of $foo in a given structure, Bob Proulx, 2008/03/19
- Re: Finding shallowest instance of $foo in a given structure, James Youngman, 2008/03/19
- Re: Finding shallowest instance of $foo in a given structure, RB, 2008/03/19
- Re: Finding shallowest instance of $foo in a given structure, James Youngman, 2008/03/19
- Re: Finding shallowest instance of $foo in a given structure, Bob Proulx, 2008/03/19
- Re: Finding shallowest instance of $foo in a given structure, RB, 2008/03/20
- Re: Finding shallowest instance of $foo in a given structure,
James Youngman <=