如何使用grep在所有名为/src的目录中递归搜索一个单词,并且只搜索*.js文件

如何使用grep在所有名为/src的目录中递归搜索一个单词,并且只搜索*.js文件,grep,Grep,在react项目中,我想在所有/src目录中搜索不区分大小写的单词“tolowercase”,只在*.js文件中搜索。使用 grep -RHlie tolowercase --include '*.js' /src 从运行man grep中详细介绍了这些选项: -R, -r, --recursive Recursively search subdirectories listed. -H Always print filename hea

在react项目中,我想在所有/src目录中搜索不区分大小写的单词“tolowercase”,只在*.js文件中搜索。

使用

grep -RHlie tolowercase --include '*.js' /src
从运行
man grep
中详细介绍了这些选项:

     -R, -r, --recursive
             Recursively search subdirectories listed.
     -H      Always print filename headers with output lines.
     -l, --files-with-matches
             Only the names of files containing selected lines are written to
             standard output.  grep will only search a file until a match has
             been found, making searches potentially less expensive.  Path-
             names are listed once per file searched.  If the standard input
             is searched, the string ``(standard input)'' is written.
     -i, --ignore-case
             Perform case insensitive matching.  By default, grep is case sen-
             sitive.
     -e pattern, --regexp=pattern
             Specify a pattern used during the search of the input: an input
             line is selected if it matches any of the specified patterns.
             This option is most useful when multiple -e options are used to
             specify multiple patterns, or when a pattern begins with a dash
             (`-').