0

I was trying to search in man find, and I would like to know what's going on.

$ man find | grep Like
             Like -lname, but the match is case insensitive.  This is a GNU
             Like -name, but the match is case insensitive.
             Like -path, but the match is case insensitive.
             Like -regex, but the match is case insensitive.
             Like -name, but the contents of the symbolic link are matched
$ man find | grep "\-name"
     find / \! -name "*.c" -print
     find /usr/src -name CVS -prune -o -depth +6 -print
     find /usr/src -name CVS -prune -o -mindepth 7 -print
$ man find | grep "name,"
             and there is no such group name, then gname is treated as a group
             and there is no such user name, then uname is treated as a user

What's going on? How come I can see lines that contain -name, but I don't get those results if I search for -name or name, and why does that show different things? I imagine it has to do with some “metadata” in man page not shown in the terminal, but I don't know.

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
Manuel
  • 513

1 Answers1

5

The default formatting from the man page (such as for bold words) is done by interspersing control characters and letters (and the control characters aren't easily visible in the output).

$ grep 'This is a GNU' /tmp/find.out
             Like -lname, but the match is case insensitive.  This is a GNU
$ grep 'This is a GNU' /tmp/find.out | od -c
0000000                                                        L   i   k
0000020    e       -  \b   -   l  \b   l   n  \b   n   a  \b   a   m  \b
0000040    m   e  \b   e   ,       b   u   t       t   h   e       m   a
0000060    t   c   h       i   s       c   a   s   e       i   n   s   e
0000100    n   s   i   t   i   v   e   .           T   h   i   s       i
0000120    s       a       G   N   U  \n

You can see the backspace/overstrike pairs in the -name word. It looks fine when printed, but means that name isn't a sequence of characters in the output.

BowlOfRed
  • 3,772