find2perl输出无法编译

时间:2016-08-24 15:04:19

标签: bash perl unix

这是我的查找命令:

find /test-data -type f -mtime +2m

然后我运行find2perl / test-data -type 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");
}

此代码会生成错误。我错过了什么错误。

语法错误在./test_older_files.pl第32行,靠近"&&打印(" $名\ n&#34)"   (可能是一个失控的多线))从第31行开始的字符串

1 个答案:

答案 0 :(得分:2)

-mtime 2m(也不是GNU' s find2perl)不支持

find

在致电find

之前,请执行以下操作
 my $time = time();

wanted子替换为以下内容:

sub wanted {
    my ($mtime);

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