【发布时间】:2016-12-31 19:18:39
【问题描述】:
这是我的查找命令:
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 行,"&& print("$name\n")" 附近的语法错误 (可能是一个失控的多行))从第 31 行开始的字符串)
【问题讨论】:
-
2m中的(int(-M _) > 2m)有问题。您必须经过几天或手动调整该线。-mtime 2m甚至对 GNUfind无效。 -
是的,谢谢,-M 只是几天,如果想要几分钟呢?
-
您可以将
time()与文件的mtime(由lstat返回)之间的差除以60。 -
minutes 在 GNU find 中是
-mmin,但 find2perl 不知道那个。 -
(int(-M _) > 2m) vs (-M _) > 2/24 作品