gpt4 book ai didi

perl - 如何使用 Perl 列出具有特定名称模式的目录下的文件?

转载 作者:行者123 更新时间:2023-12-05 08:44:47 30 4
gpt4 key购买 nike

我有一个目录/var/spool,里面的目录名为

a  b  c  d  e  f  g  h i  j  k  l  m  n  o  p q  r  s  t  u  v  x  y z

And inside each "letter directory", a directory called "user" and inside this, many directories called auser1 auser2 auser3 auser4 auser5 ...

Every user directory contains mail messages and the file names have the following format: 2. 3. 4. 5. etc.

How can I list the email files for every user in every directory in the following way:

    /var/spool/a/user/auser1/11.    /var/spool/a/user/auser1/9.    /var/spool/a/user/auser1/8.    /var/spool/a/user/auser1/10.    /var/spool/a/user/auser1/2.    /var/spool/a/user/auser1/4.    /var/spool/a/user/auser1/12.    /var/spool/b/user/buser1/12.    /var/spool/b/user/buser1/134.    /var/spool/b/user/buser1/144.

etc.

I need that files and then open every single file for modify the header and body. This part I already have, but I need the first part.

I am trying this:

dir = "/var/spool";

opendir ( DIR, $dir ) || die "No pude abrir el directorio $dirname\n";
while( ($filename = readdir(DIR))){
@directorios1 = `ls -l "$dir/$filename"`;
print("@directorios1\n");
}
closedir(DIR);

但没有按我需要的方式工作。

最佳答案

您可以使用 File::Find .

关于perl - 如何使用 Perl 列出具有特定名称模式的目录下的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1707693/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com