如何只列出文件而不列出目录Bash的目录? [英] How to list only files and not directories of a directory Bash?

查看:144
本文介绍了如何只列出文件而不列出目录Bash的目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何列出一个文件夹的所有文件,而不列出它们的文件夹或子文件.换句话说:如何只列出文件?

How can I list all the files of one folder but not their folders or subfiles. In other words: How can I list only the files?

推荐答案

使用find:

find . -maxdepth 1 -type f

使用-maxdepth 1选项可确保仅查看当前目录(或者,如果使用某些路径替换.,则该目录).如果您想要该目录和子目录中所有文件的完整递归列表,只需删除该选项即可.

Using the -maxdepth 1 option ensures that you only look in the current directory (or, if you replace the . with some path, that directory). If you want a full recursive listing of all files in that and subdirectories, just remove that option.

这篇关于如何只列出文件而不列出目录Bash的目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆