Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux Bash在目录中的文件中查找代码行_Linux_Bash_Shell_Directory - Fatal编程技术网

Linux Bash在目录中的文件中查找代码行

Linux Bash在目录中的文件中查找代码行,linux,bash,shell,directory,Linux,Bash,Shell,Directory,我如何才能找到这条线: print("hello world)" 在目录x/y/z中,文件可以位于x树的任何分支中(其中目录x有许多子文件夹,您可以从x的父目录使用递归grep: grep -FR 'print("hello world)"' x/* 由于您要查找的行看起来像一些代码,您可能对使用标志“--include”:grep-FR--include.c”print(“hello world”)感兴趣'x/以查找c代码文件为例。是的,我也会包含--include=,但问题中没有提到要

我如何才能找到这条线:

 print("hello world)"

在目录x/y/z中,文件可以位于x树的任何分支中(其中目录x有许多子文件夹,您可以从
x
的父目录使用递归
grep

grep -FR 'print("hello world)"' x/*

由于您要查找的行看起来像一些代码,您可能对使用标志“--include”:grep-FR--include.c”print(“hello world”)感兴趣'x/以查找c代码文件为例。是的,我也会包含
--include=
,但问题中没有提到要搜索的文件扩展名是
F
标志,因此不需要转义?是
F
用于固定字符串,因此模式不被视为正则表达式。