grep 不显示结果

grep 不显示结果

我正在尝试搜索man find,我想知道发生了什么事。

$ 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

这是怎么回事?为什么我可以看到包含的行,但如果我搜索or-name,却得不到这些结果,为什么会显示不同的内容?我想这与终端中未显示的手册页中的一些“元数据”有关,但我不知道。-namename,

答案1

手册页中的默认格式(例如粗体字)是通过散布控制字符和字母来完成的(并且控制字符在输出中不容易看到)。

$ 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

您可以在 -name 单词中看到退格/重打对。打印时看起来不错,但这意味着这name不是输出中的字符序列。

相关内容