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