How can I quickly check if Linux `unzip` is installed using Perl?

如何快速检查是否使用Perl安装了Linux unzip


Just run it.

Seriously.

Presumably, the reason why you want to know if it is installed, is because you need to run it later. In that case, it isn't enough to know whether it is installed, anyway – you also need to know whether it is executable, whether it is in the path, whether the user id the script is running under has the necessary privileges to run it, and so on. You can check all that by simply just running it.


`which unzip`

If there's output, it points to unzip's location. If there isn't output, then nothing will show up. This relies on unzip being on your path.


这将验证unzip命令是否在您的路径上,以及是否可以由当前用户执行。

print "unzip installed" if grep { -x "$_/unzip"}split /:/,$ENV{PATH}
链接地址: http://www.djcxy.com/p/57068.html

上一篇: 找出POSIX系统上是否存在命令

下一篇: 我如何快速检查Linux是否使用Perl安装了unzip?