可以简单地使用 grep 在目录结构中查找文件吗?

Sly*_*Fly 4 grep

我喜欢使用 grep 但有时我只想在目录树中搜索文件的名称,但不希望 grep 打开文件并在其中搜索。grep 可以这样做吗?

Phi*_*ack 5

这个问题有很多答案,但最“正确”的传统 unix 答案是使用 find(1):

find / -type f -name foo\*
Run Code Online (Sandbox Code Playgroud)

将查找当前目录下名称以 foo