Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash find2perl输出不编译_Bash_Perl_Unix - Fatal编程技术网

Bash find2perl输出不编译

Bash find2perl输出不编译,bash,perl,unix,Bash,Perl,Unix,这是我的查找命令: find /test-data -type f -mtime +2m 然后运行find2perl/test数据类型f-mtime+2m。它产生: #! /usr/bin/perl -w eval 'exec /usr/bin/perl -S $0 ${1+"$@"}' if 0; #$running_under_some_shell use strict; use File::Find (); # Set the variable $File::

这是我的查找命令:

find /test-data -type f -mtime +2m
然后运行find2perl/test数据类型f-mtime+2m。它产生:

#! /usr/bin/perl -w
    eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
        if 0; #$running_under_some_shell

use strict;
use File::Find ();

# Set the variable $File::Find::dont_use_nlink if you're using AFS,
# since AFS cheats.

# for the convenience of &wanted calls, including -eval statements:
use vars qw/*name *dir *prune/;
*name   = *File::Find::name;
*dir    = *File::Find::dir;
*prune  = *File::Find::prune;

sub wanted;



# Traverse desired filesystems
File::Find::find({wanted => \&wanted}, '/test-data');
exit;


sub wanted {
    my ($dev,$ino,$mode,$nlink,$uid,$gid);

    (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
    -f _ &&
    (int(-M _) > 2m)
    && print("$name\n");
}
此代码生成错误。我错过了什么是错的

“&&print($name\n)”附近的./test_older_files.pl第32行出现语法错误
(可能是失控的多行)从第31行开始的字符串。

-mtime 2m
不受
find2perl
的支持(GNU的
find
也不支持)

在调用
find
之前放置以下内容:

 my $time = time();
用以下内容替换所需的
子项:

sub wanted {
    my ($mtime);

    ( ($mtime) = ( lstat($_) )[9] ) &&
    -f _ &&
    ( $time-$mtime >= 2*60 )
    && print("$name\n");
}

-mtime2m
不受
find2perl
支持(GNU的
find
也不支持)

在调用
find
之前放置以下内容:

 my $time = time();
用以下内容替换所需的
子项:

sub wanted {
    my ($mtime);

    ( ($mtime) = ( lstat($_) )[9] ) &&
    -f _ &&
    ( $time-$mtime >= 2*60 )
    && print("$name\n");
}

(int(-M)>2m)
中的
2m
有问题。您必须经过几天的时间或手动调整该行
-mtime 2m
对GNU
find
甚至无效。是的,谢谢,-M只是几天,如果需要几分钟怎么办?你可以将
time()
和文件的
mtime
(由
lstat
方便地返回)之间的差值除以60。在GNU find中,分钟将是
-mmin
,但是find2perl不知道这一点。(int(-M)>2m)vs(-M)>2/24工作
中的
2m
(int(-M)>2m)
是有问题的。您必须经过几天的时间或手动调整该行
-mtime 2m
对GNU
find
甚至无效。是的,谢谢,-M只是几天,如果需要几分钟怎么办?你可以将
time()
和文件的
mtime
(由
lstat
方便地返回)之间的差值除以60。在GNU find中,分钟将是
-mmin
,但是find2perl不知道这一点。(int(-M)>2m)vs(-M)>2/24有效