获取包含完整路径的文件列表
我想获取目录层次结构中所有文件的列表(就像我使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于此类事情,请使用
find
。将列出位于
/home/me/subdir
中的所有文件和目录以及完整路径。只会列出文件。 (
-type d
用于目录。)如果您需要匹配文件名 glob,请执行以下操作:
或排除文件名模式:
Use
find
for this type of thing.will list all the files and directories, with full path, that live in
/home/me/subdir
.will only list files. (
-type d
for directories.)If you need to match a filename glob, do like this:
Or exclude a file name pattern: