简体   繁体   English

在文件夹和子文件夹中查找所有文件的另一种方法

[英]Alternative way to find all files in a folder and subfolders

Is there any alternative for below command to find files in a folder and subfolders as well. 下面的命令是否还有其他选择,也可以在文件夹和子文件夹中查找文件。

find . | egrep '\./[^/]+/[^/]+/[^/]+'

Note: I don't want directories I want to get only files 注意:我不希望目录仅获取文件

Additionally, you could specify list of files extensions as your search options: 此外,您可以指定文件扩展名列表作为搜索选项:

find . -type f -name "*.js" -o -name "*.ros" -o -name "*.php"

Above example, would only display file names with *.ros, *.php, and *.js as file extensions under specific folder and subfolders. 上面的示例仅显示带有* .ros,*。php和* .js的文件名,作为特定文件夹和子文件夹下的文件扩展名。

Why don't you just use find? 您为什么不只使用find? I am not sure from your question if you want to limit the depth. 从您的问题中我不确定您是否要限制深度。 If so: 如果是这样的话:

find . -type f -depth 2 -print

If you just want to find files 如果您只想查找文件

find . -type f -print

If you just want to find directories 如果您只想查找目录

find . -type d -print

You can also use -ls if -print does not float your boat. 如果-print没有使您的船浮起,您也可以使用-ls。

find . -type f -ls

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何监控包含所有子文件夹和文件的文件夹? - How to monitor a folder with all subfolders and files inside? 消除子文件夹,将所有文件移动到一个文件夹中 - Eliminating subfolders to move all files into one folder 如何删除//当前文件夹和子文件夹中所有文件中的注释行? - How to delete // comment lines in all files in current folder and subfolders? 在子文件夹的文件中找到tekst - find tekst in files in subfolders 从 Mac 上的命令行删除当前文件夹和所有子文件夹中的 .DS_STORE 文件 - Delete .DS_STORE files in current folder and all subfolders from command line on Mac 如何递归地将文件夹及其所有子文件夹和文件设置为 drwxrwxrwx - How do I recursively set a folder and all of its subfolders and files to drwxrwxrwx 在Linux上删除包含子文件夹和文件的文件夹 - Delete folder that contain subfolders and files on linux 使用Python计算所有文件夹/子文件夹中的所有文件 - Count all files in all folders/subfolders with Python 如何基于正则表达式递归查找当前文件夹和子文件夹中的所有文件 - How can I recursively find all files in current and subfolders based on regular expressions 如何根据通配符匹配递归查找当前文件夹和子文件夹中的所有文件? - How can I recursively find all files in current and subfolders based on wildcard matching?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM