如何递归列出所有文件和目录 [英] How to recursively list all files and directories

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

问题描述

使用Free BSD上的tcsh shell,是否有一种方法可以递归列出所有文件和目录,包括文件的所有者,组和相对路径?

Using the tcsh shell on Free BSD, is there a way to recursively list all files and directories including the owner, group and relative path to the file?

ls -alR接近,但没有在每个文件的前面显示相对路径,而是在分组的顶部(即,

ls -alR comes close, but it does not show the relative path in front of every file, it shows the path at the top of a grouping i.e.

owner% ls -alR
total 0
drwxr-xr-x   3 owner  group  102 Feb  1 10:50 .
drwx------+ 27 owner  group  918 Feb  1 10:49 ..
drwxr-xr-x   5 owner  group  170 Feb  1 10:50 subfolder

./subfolder:
total 16
drwxr-xr-x  5 owner  group   170 Feb  1 10:50 .
drwxr-xr-x  3 owner  group   102 Feb  1 10:50 ..
-rw-r--r--  1 owner  group     0 Feb  1 10:50 file1
-rw-r--r--  1 owner  group     0 Feb  1 10:50 file2

我想要的输出是:

owner group ./relative/path/to/file

对此问题的已接受答案问题显示文件的相对路径,但不显示所有者和组.

The accepted answer to this question shows the relative path to a file, but does not show the owner and group.

推荐答案

这是怎么回事:

find . -exec ls -dl \{\} \; | awk '{print $3, $4, $9}'

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

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