Linux 如何递归搜索具有某些扩展名的文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5985752/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 04:03:17  来源:igfitidea点击:

How to recursively search for files with certain extensions?

linuxgrepfindls

提问by StackOverflowNewbie

I need to find all the .psdfiles on my Linux system (dedicated web hosting). I tried something like this: ls -R *.psd, but that's not working. Suggestions?

我需要.psd在我的 Linux 系统(专用网络托管)上找到所有文件。我尝试过这样的事情:ls -R *.psd,但这不起作用。建议?

采纳答案by onteria_

You can use the following find command to do that:

您可以使用以下 find 命令来执行此操作:

find /path/to/search -iname '*.psd'

inamedoes a case insensitive search.

iname进行不区分大小写的搜索。

回答by jm666

you also can

你也可以

ls ./**/*.psd

but:

但:

  • you must have bash version 4+
  • you must have shopt -s globstar#in your .bashrc or .profile, etc....
  • will search case sensitive (or you must set shopt -s nocaseglobtoo)
  • 你必须有 bash 版本 4+
  • 你必须在shopt -s globstar你的 .bashrc 或 .profile 等中#in。
  • 将搜索区分大小写(或者您也必须设置shopt -s nocaseglob