Re: Add examples to show depth

Bernhard Voelker <[email protected]>
Newsgroups gmane.comp.gnu.findutils.bugs
Message-ID <[email protected]>
On 2020-07-22 14:00, 積丹尼 Dan Jacobson wrote:
> (info "(find) Directories") says
> 
>  -- Option: -maxdepth levels
>      Descend at most LEVELS (a non-negative integer) levels of
>      directories below the command line arguments.  '-maxdepth 0' means
>      only apply the tests and actions to the command line arguments.
> 
>  -- Option: -mindepth levels
>      Do not apply any tests or actions at levels less than LEVELS (a
>      non-negative integer).  '-mindepth 1' means process all files
>      except the command line arguments.
> 
> OK that is great, but not clear without examples.
> 
> Something like
> $ find -name Makefile
> ./comm/radio/radioscanningtw/maps/Makefile
> ./comm/air/m750/programs/a/Makefile
> ./comm/air/routes/programs/Makefile
> $ find -maxdepth 4 -name Makefile
> $ find -maxdepth 5 -name Makefile
> ./comm/radio/radioscanningtw/maps/Makefile
> ./comm/air/routes/programs/Makefile
> etc.

Thanks for the suggestion.  Fixed with the attached:

  [PATCH] doc: add examples for -maxdepth, -mindepth

Have a nice day,
Berny
0001-doc-add-examples-for-maxdepth-mindepth.patch (text/x-patch, 1.5 KB)
From 2c15992f5166ec983d5f800a08776aeb33a239d3 Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <[email protected]>
Date: Tue, 28 Jul 2020 21:32:45 +0200
Subject: [PATCH] doc: add examples for -maxdepth, -mindepth
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* doc/find.texi (-maxdepth): Add examples.
(-mindepth): Reference them.

Suggested by 積丹尼 Dan Jacobson <[email protected]> in
https://lists.gnu.org/r/bug-findutils/2020-07/msg00006.html
---
 doc/find.texi | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/doc/find.texi b/doc/find.texi
index 1e4ab177..ce63ca52 100644
--- a/doc/find.texi
+++ b/doc/find.texi
@@ -1358,12 +1358,31 @@ slice of a directory tree.
 Descend at most @var{levels} (a non-negative integer) levels of
 directories below the command line arguments.  @samp{-maxdepth 0}
 means only apply the tests and actions to the command line arguments.
+
+@example
+$ mkdir -p dir/d1/d2/d3/d4/d5/d6
+
+$ find dir -maxdepth 1
+dir
+dir/d1
+
+$ find dir -mindepth 5
+dir/d1/d2/d3/d4/d5
+dir/d1/d2/d3/d4/d5/d6
+
+$ find dir -mindepth 2 -maxdepth 4
+dir/d1/d2
+dir/d1/d2/d3
+dir/d1/d2/d3/d4
+@end example
 @end deffn
 
 @deffn Option -mindepth levels
 Do not apply any tests or actions at levels less than @var{levels} (a
 non-negative integer).  @samp{-mindepth 1} means process all files
 except the command line arguments.
+
+See @samp{-maxdepth} for examples.
 @end deffn
 
 @deffn Option -depth
-- 
2.28.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.