How to recursively list all files and directories

前端 未结 8 1750
长发绾君心
长发绾君心 2021-02-01 03:32

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 cl

8条回答
  •  鱼传尺愫
    2021-02-01 04:15

    If you fancy using Perl don't use it as a wrapper around shell commands. Doing it in native Perl is faster, more portable, and more resilient. Plus it avoids ad-hoc regexes.

    use File::Find;
    use File::stat;
    
    find (\&myList, ".");
    
    sub myList {
       my $st = lstat($_) or die "No $file: $!";
    
       print  getgrnam($st->gid), " ", 
              getpwuid($st->uid), " ", 
              $File::Find::name, "\n";
    }
    

提交回复
热议问题