From d4f2e4453e06920f1d14804c1cfa9b3f81d8dd39 Mon Sep 17 00:00:00 2001 From: James Youngman Date: Thu, 25 Feb 2010 11:06:53 +0000 Subject: [PATCH] Explain the problems with "-name a/b" and "-path foo/". To: address@hidden * find/find.1 (-iname): We already refer to -name, so duplicate less text. (-name): Explain that -name a/b will never match anything. * doc/find.texi (Base Name Patterns): Explain that -name a/b will never match anything. (Full Name Patterns): Fix typo. Signed-off-by: James Youngman --- ChangeLog | 10 ++++++++++ doc/find.texi | 9 +++++++-- find/find.1 | 16 +++++++++------- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 50df6c1..03fffbc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2010-02-25 James Youngman + + Explain the problems with "-name a/b" and "-path foo/". + * find/find.1 (-iname): We already refer to -name, so duplicate + less text. + (-name): Explain that -name a/b will never match anything. + * doc/find.texi (Base Name Patterns): Explain that -name a/b will + never match anything. + (Full Name Patterns): Fix typo. + 2010-02-22 James Youngman * xargs/xargs.1: Simplify the wording in the description of "xargs diff --git a/doc/find.texi b/doc/find.texi index 7820c43..c2c2c03 100644 --- a/doc/find.texi +++ b/doc/find.texi @@ -404,6 +404,11 @@ example the command @samp{find /tmp -name \*bar} will match the file considered to be special (that is, @code{find . -name 'address@hidden,address@hidden'} matches a file named @address@hidden,address@hidden, not the files @file{foo1} and @file{foo2}. + +Because the leading directories are removed, the file names considered +for a match with @samp{-name} will never include a slash, so address@hidden a/b} will never match anything (you probably need to use address@hidden instead). @end deffn @@ -428,8 +433,8 @@ arguments ending in @samp{/} will match nothing (except perhaps a start point specified on the command line). The name @samp{-wholename} is GNU-specific, but @samp{-path} is more -portable; it is supported by HP-UX @code{find} and is of the POSIX -2008 standard. +portable; it is supported by HP-UX @code{find} and is part of the +POSIX 2008 standard. @end deffn diff --git a/find/find.1 b/find/find.1 index b27311a..e17b21e 100644 --- a/find/find.1 +++ b/find/find.1 @@ -584,12 +584,8 @@ Like .BR \-name , but the match is case insensitive. For example, the patterns `fo*' and `F??' match the file names `Foo', `FOO', `foo', -`fOo', etc. In these patterns, unlike filename expansion by the -shell, an initial `.' can be matched by `*'. That is, -.B find \-name *bar -will match the file `.foobar'. Please note that you should quote -patterns as a matter of course, otherwise the shell will expand any -wildcard characters in them. +`fOo', etc. The pattern `*foo*` will also match a file +called '.foobar'. .IP "\-inum \fIn\fR" File has inode number \fIn\fR. It is normally easier to use the @@ -635,7 +631,13 @@ modification times. .IP "\-name \fIpattern\fR" Base of file name (the path with the leading directories removed) -matches shell pattern \fIpattern\fR. The metacharacters (`*', `?', +matches shell pattern \fIpattern\fR. Because the leading directories +are removed, the file names considered for a match with +.B \-name +will never include a slash, so `-name a/b' will never match anything +(you probably need to use +.B \-path +instead). The metacharacters (`*', `?', and `[]') match a `.' at the start of the base name (this is a change in findutils-4.2.2; see section STANDARDS CONFORMANCE below). To ignore a directory and the files under it, use -- 1.5.6.5