Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果文件名具有像“@”这样的字符,perl 的 stat() 似乎不起作用。
-rw-r--r-- 1 root root 0 Mar 1 17:33 /tmp/mark@er.txt
使用的 Perl 命令:
#perl -e 'my $modtime = (stat("/tmp/mark@er.txt"))[9]|| die "$!"' No such file or directory at -e line 1.
谁能帮助如何为 stat() 转义这些字符?
perl在那里“看到”一个@er数组,所以你正在stating /tmp/mark.txt。试试这个:
perl
@er
stat
/tmp/mark.txt
perl -e 'my $modtime = (stat("/tmp/mark\@er.txt"))[9] || die "$!"'
或者您可以使用非插值单引号q()(thanks amon)
q()
perl -e 'my $modtime = (stat(q(/tmp/mark@er.txt)))[9] || die "$!"'