获取包含完整路径的文件列表

发布于 2024-10-22 02:43:16 字数 84 浏览 7 评论 0原文

我想获取目录层次结构中所有文件的列表(就像我使用 ls -R 那样),但是这样不是列出目录名称及其下面的文件,而是只会输出文件列表及其完整路径。这可能吗?

I would like to get a list of all the files in a directory hierarchy (like I would with ls -R), but such that instead of listing the name of the directory and its files beneath it, it would just output a list of files with their full path. Is this possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

幸福不弃 2024-10-29 02:43:16

对于此类事情,请使用 find

find /home/me/subdir

将列出位于 /home/me/subdir 中的所有文件和目录以及完整路径。

find /home/me/subdir -type f

只会列出文件。 (-type d 用于目录。)

如果您需要匹配文件名 glob,请执行以下操作:

find /home/me/subdir -type f -name "abc*"

或排除文件名模式:

find /home/me/subdir -type f ! -name ".*"

Use find for this type of thing.

find /home/me/subdir

will list all the files and directories, with full path, that live in /home/me/subdir.

find /home/me/subdir -type f

will only list files. (-type d for directories.)

If you need to match a filename glob, do like this:

find /home/me/subdir -type f -name "abc*"

Or exclude a file name pattern:

find /home/me/subdir -type f ! -name ".*"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文