Do the following:

grep -rnw '/path/to/somewhere/' -e 'pattern'
  • -r or -R is recursive,
  • -n is line number, and
  • -w stands for match the whole word.
  • -l (lower-case L) can be added to just give the file name of matching files.

Along with these, --exclude, --include, --exclude-dir flags could be used for efficient searching:

  • This will only search through those files which have .c or .h extensions:

    grep --include=\*.{c,h} -rnw '/path/to/somewhere/' -e "pattern"
    
  • This will exclude searching all the files ending with .o extension:

    grep --exclude=*.o -rnw '/path/to/somewhere/' -e "pattern"
    
  • For directories it's possible to exclude a particular directory(ies) through --exclude-dir parameter. For example, this will exclude the dirs dir1/, dir2/ and all of them matching *.dst/:

    grep --exclude-dir={dir1,dir2,*.dst} -rnw '/path/to/somewhere/' -e "pattern"
    

This works very well for me, to achieve almost the same purpose like yours.

For more options check man grep.

Linux下各种查找命令(find, grep, which, whereis, locate)_carl的 ...

https://blog.csdn.net/wzzfeitian/article/details/40985549

2014年11月10日 ... find命令find path: 所要搜索的目录及其所有子目录。 ... -s num 命令行的最大字符 数,指的是xargs后面那个命令的最大命令行字符数 ... Linux下查找某一文件所在的 路径比较实用的两个命令: 1. whereis 文件名2. locate -文件名 ... 它来查找文件夹 ,用法跟查找文件类似,只要在最后面指明查找的文件类型-type d, ...

How to Find Files and Folders in Linux Using the Command Line

https://www.howtogeek.com/112674/how-to-find-files-and-folders-in-linux-using-the-command-line/

Jul 3, 2017 ... Using the Find Command. The “findcommand allows you to search for files for which you know the approximate filenames. The simplest form of ...

Linux find查找文件及文件夹命令_m0_37568814的博客-CSDN博客_ ...

https://blog.csdn.net/m0_37568814/article/details/82753281

2018年9月18日 ... -print:将结果打印到屏幕上,为默认操作。 查找目录:find /(查找范围) -name ' 查找关键字' -type d. AnmyTest目录下有个AnmyTest ...

搜索Linux 中的文件和文件夹的四种简单方法- 知乎

https://zhuanlan.zhihu.com/p/52746102

2018年12月18日 ... 了解一些搜索的东西是不错的,因为这能帮助你在命令行服务器中工作。这些命令 记忆起来不复杂,因为它们使用的是标准语法。 可以通过四个 ...

How to search files from the Terminal on Linux

https://www.howtoforge.com/tutorial/linux-search-files-from-the-terminal/

The “locate” command is the first resort that a Linux user should utilize ... For this reason, I would navigate to my download folder through the terminal with “cd ...

Linux中grep查找含有某字符串的所有文件_BabyFish13-CSDN博客

https://blog.csdn.net/BabyFish13/article/details/79709028

2018年3月27日 ... 表示当前目录所有文件,也可以是某个文件名 ... 有意思的命令行参数: ... Linux grep命令用于查找文件里符合条件的字符串 ... 在文件夹下所有文件查找grep 'string' dirPath/* 补充:若目录下含有多级子目录,则用grep -r "string" .

linux查找文件,文件夹某个目录下包含某个字符串的文件- 华为云

https://www.huaweicloud.com/articles/a69e4f1b98f69fdfba7d8e2c45908044.html

2019年10月15日 ... 一、查找文件存放地点 1、locate 语法:locate locate命令实际是"find -name"的另 一种写法,但是...

Linux查找文件、文件夹- 简书

https://www.jianshu.com/p/f3a46e5c96ba

1.引入nacos依赖由于多个模块使用到nacos作为配置,所以在mymail-common 公共模块的pom文件... 初晴H阅读352评论0赞7. Android studio使用已经编译好 ...

Ways to Use 'find' Command to Search Directories More Efficiently

https://www.tecmint.com/find-directory-in-linux/

Nov 22, 2016 ... And one of the common things a Linux user will do within the command line is searching for a file or a directory. There are several different ...

How to find a directory on linux? - Super User

https://superuser.com/questions/327762/how-to-find-a-directory-on-linux

98 It may not matter for simple searches, but for more complex find commands, it's worth noting that things are evaluated in the order they are on the commandline.

Linux 常用命令学习| 菜鸟教程

https://www.runoob.com/w3cnote/linux-common-command-2.html

1、ls命令就是list 的缩写,通过ls 命令不仅可以查看linux 文件夹包含的文件,而且 ... 注意:命令行复制,如果目标文件已经存在会提示是否覆盖,而在shell 脚本中, ... which 是在PATH 就是指定的路径中,搜索某个系统命令的位置,并返回第一个 ...

How do I find all files containing specific text on Linux? - Stack ...

https://stackoverflow.com/questions/16956810/how-do-i-find-all-files-containing-specific-text-on-linux

This will print the lines in the files where the text appears, but it does not print ... In addition to this command, we can write this too: grep -rn "String to search" ... You can use grep tool to search recursively the current folder, like:

Finding a directory in a Linux Terminal - Super User

https://superuser.com/questions/159290/finding-a-directory-in-a-linux-terminal

Would you be looking for something like this? find . -type d | grep DIRNAME.

Find Command in Linux (Find Files and Directories) | Linuxize

https://linuxize.com/post/how-to-find-files-in-linux-using-the-command-line/

Nov 19, 2020 ... Find Files in Linux Using the Command Line. The find command is one of the most powerful tools in the Linux system administrators arsenal.

How to Search for Files from the Linux Command Line - Linux.com

https://www.linux.com/topic/desktop/how-search-files-linux-command-line/

Nov 1, 2018 ... It goes without saying that every good Linux desktop environment offers the ability to search your file system for files and folders. If your default ...

How to find files on the Ubuntu command line

https://vitux.com/how-to-find-files-on-the-ubuntu-command-line/

Jun 20, 2019 ... While working under Linux, regardless of the distribution, many GUI ... Using the Find command you can search based on file and folder name, ...

How to Find Files in Linux Using the Command Line | Linode

https://www.linode.com/docs/guides/find-files-in-linux-using-the-command-line/

Oct 25, 2010 ... notx it reports no files or folders found. If I search find /Documents study.notx it still can't find it. How is that possible? What am I doing ...