为什么';递归grep看起来有效吗?

为什么';递归grep看起来有效吗?,grep,Grep,grep的手册页显示: -r, --recursive Read all files under each directory, recursively 好的,那么这怎么可能呢: # grep -r BUILD_AP24_TRUE apache # grep BUILD_AP24_TRUE apache/Makefile.in @BUILD_AP24_TRUE@mod_shib_24_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \ (..

grep
的手册页显示:

-r, --recursive
          Read all files under each directory, recursively
好的,那么这怎么可能呢:

# grep -r BUILD_AP24_TRUE apache
# grep BUILD_AP24_TRUE apache/Makefile.in
@BUILD_AP24_TRUE@mod_shib_24_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
(...)

此类问题可能有两个原因:

  • grep
    的别名不包括您感兴趣的文件

  • 感兴趣的文件位于符号链接目录中或其本身是符号链接

  • 在你的情况下,这似乎是第二个原因。一种解决方案是使用
    grep-R
    代替
    grep-R
    。从
    man grep

       -r, --recursive
              Read  all files under each directory, recursively, following symbolic
              links only if they are on the command line.  Note that if no file
              operand is given, grep searches the working directory.
              This is equivalent to the -d recurse option.
    
       -R, --dereference-recursive
              Read all files under each directory, recursively.
              Follow all symbolic links, unlike -r.
    

    command-v grep
    的输出是什么?@John1024您正在询问的命令的输出是
    /bin/grep
    ,因此它不是某种类型的别名
    grep-R BUILD\u AP24\u TRUE apache
    ,并告诉我们发生了什么。@John1024是的,这很尴尬,我没有检查
    Makefile.in
    是一个符号链接。。。因为,此文件不是符号链接。除了,在这种情况下,它是。我想和做这个符号链接的人单独呆5分钟。