How to recursively list all files and directories

2019-03-11 17:45发布

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 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

What I would like is output like:

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.

标签: linux shell
7条回答
混吃等死
2楼-- · 2019-03-11 18:18

You've already got an answer that works, but for reference you should be able to do this on the BSDs (I've tested it on a mac) :

find . -ls
查看更多
登录 后发表回答