【问题标题】:what is use of `test -x` in Perl script execution [duplicate]Perl脚本执行中`test -x`的用途是什么[重复]
【发布时间】:2019-03-26 14:17:08
【问题描述】:

我是 Perl 新手!!!我在 sun OS 机器中有一个旧的 crontab 条目来运行类似于 10 * * * * test -x $path/abc.pl && $path/abc.pl >/dev/nul 的 Perl 脚本。 我想知道在这次执行中使用术语test -x 有什么用。

【问题讨论】:

标签: linux shell


【解决方案1】:

test 检查文件类型(和权限)。
test -x FILE 检查文件是否存在并授予执行(或搜索)权限。
所以,只有$path/abc.pl是一个已有文件,并且当前用户有执行权限,才会被执行。

参考:
https://linux.die.net/man/1/test

顺便说一句,这与 Perl 无关,虽然 Perl 有类似的功能:
https://perldoc.perl.org/functions/-X.html

【讨论】:

  • 您可能要补充一点,它与 Perl 无关。
  • @simbabque 添加。谢谢。
猜你喜欢
  • 2010-12-20
  • 2016-09-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-29
  • 1970-01-01
  • 2016-10-10
  • 2012-05-06
相关资源
最近更新 更多