find(1) man page

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

find(1) man page

J.C. Roberts-2
Just a small, one sentence addition/clarification on pattern matching
for the ``-name pattern'' entry of the find(1) man page.


OLD:
-name pattern
    True if the last component of the pathname being examined matches
    pattern.  Special shell pattern matching characters (`[', `]',
    `*', and `?') may be used as part of pattern.  These characters
    may be matched explicitly by escaping them with a backslash
    (`\').

NEW:
-name pattern
    True if the last component of the pathname being examined matches
    pattern.  Special shell pattern matching characters (`[', `]',
    `*', and `?') may be used as part of pattern.  These characters
    may be matched explicitly by escaping them with a backslash
    (`\').  If your shell is already using the backslash (`\') as an
    escape character, you will need to use the backslash twice (`\\')
    to explicitly match the special characters.


TEST:
    # echo $SHELL
    /bin/ksh
    # mkdir -p /tmp/test
    # cd /tmp/test
    # touch \*test
    # touch \?test
    # touch \[test
    # touch \]test
    # ls -l
    total 0
    -rw-r--r--  1 root  wheel  0 Dec 26 00:36 *test
    -rw-r--r--  1 root  wheel  0 Dec 26 00:36 ?test
    -rw-r--r--  1 root  wheel  0 Dec 26 00:36 [test
    -rw-r--r--  1 root  wheel  0 Dec 26 00:36 ]test
    # find . -name \*test -print
    ./*test
    ./?test
    ./[test
    ./]test
    # find . -name \\*test -print
    ./*test
    #


PATCH:

--- src/usr.bin/find/find.1.old Mon Dec 26 00:25:13 2005
+++ src/usr.bin/find/find.1 Mon Dec 26 00:58:17 2005
@@ -283,6 +283,11 @@
 These characters may be matched explicitly by escaping them with a
 backslash
 .Pq Ql \e .
+If your shell is already using the backslash
+.Pq Ql \e
+as an escape character, you will need to use the backslash twice
+.Pq Ql \e\e
+to explicitly match the special characters.
 .It Ic -newer Ar file
 True if the current file has a more recent last modification time than
 .Ar file .

Reply | Threaded
Open this post in threaded view
|

Re: find(1) man page

Jason McIntyre-2
On Mon, Dec 26, 2005 at 01:05:47AM -0800, J.C. Roberts wrote:

>
> PATCH:
>
> --- src/usr.bin/find/find.1.old Mon Dec 26 00:25:13 2005
> +++ src/usr.bin/find/find.1 Mon Dec 26 00:58:17 2005
> @@ -283,6 +283,11 @@
>  These characters may be matched explicitly by escaping them with a
>  backslash
>  .Pq Ql \e .
> +If your shell is already using the backslash
> +.Pq Ql \e
> +as an escape character, you will need to use the backslash twice
> +.Pq Ql \e\e
> +to explicitly match the special characters.
>  .It Ic -newer Ar file
>  True if the current file has a more recent last modification time than
>  .Ar file .

this is already covered by the first paragraph of BUGS.
jmc

Reply | Threaded
Open this post in threaded view
|

Re: find(1) man page

Tom Cosgrove-2
>>> Jason McIntyre 26-Dec-05 09:27 >>>
>
> On Mon, Dec 26, 2005 at 01:05:47AM -0800, J.C. Roberts wrote:
> >
> > PATCH:
> >
> > --- src/usr.bin/find/find.1.old Mon Dec 26 00:25:13 2005
> > +++ src/usr.bin/find/find.1 Mon Dec 26 00:58:17 2005
> > @@ -283,6 +283,11 @@
> >  These characters may be matched explicitly by escaping them with a
> >  backslash
> >  .Pq Ql \e .
> > +If your shell is already using the backslash
> > +.Pq Ql \e
> > +as an escape character, you will need to use the backslash twice
                                      ^^^^
> > +.Pq Ql \e\e
> > +to explicitly match the special characters.
> >  .It Ic -newer Ar file
> >  True if the current file has a more recent last modification time than
> >  .Ar file .
>
> this is already covered by the first paragraph of BUGS.
> jmc

Particularly as you do not 'need' to use the backslash to escape
characters from the shell, so the diff as presented is inaccurate,
anyway.

    tau $ ls -l
    total 0
    -rw-r--r--  1 tom  wheel  0 Dec 26 10:47 *test
    -rw-r--r--  1 tom  wheel  0 Dec 26 10:47 ?test
    -rw-r--r--  1 tom  wheel  0 Dec 26 10:47 [test
    -rw-r--r--  1 tom  wheel  0 Dec 26 10:47 ]test
    tau $ find . -name '*test' -print
    ./*test
    ./?test
    ./[test
    ./]test
    tau $ find . -name '\*test' -print
    ./*test


Thanks

Tom