首页 > 解决方案 > 如何使用命令行检查是否安装了 c-blosc?

问题描述

command -v c-blosc即使已安装,使用也不会返回任何内容

c-blosc 将自己描述为一个压缩库,所以它不是一个命令


我尝试过的几件事

% c-blosc
zsh: command not found: c-blosc
where c-blosc
c-blosc not found
brew install c-blosc
...
Warning: c-blosc 1.21.0 is already installed and up-to-date.
To reinstall 1.21.0, run:
  brew reinstall c-blosc

% brew info c-blosc
c-blosc: stable 1.21.0 (bottled)
Blocking, shuffling and loss-less compression library
https://blosc.org/
/usr/local/Cellar/c-blosc/1.21.0 (10 files, 1.7MB) *
  Poured from bottle on 2021-07-07 at 23:44:40
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/c-blosc.rb
License: BSD-3-Clause
==> Dependencies
Build: cmake ✘
==> Analytics
install: 312 (30 days), 1,190 (90 days), 3,168 (365 days)
install-on-request: 249 (30 days), 998 (90 days), 2,263 (365 days)
build-error: 0 (30 days)
brew search c-blosc 
==> Formulae
c-blosc ✔

以下

if [ brew info c-blosc 2>&1 >/dev/null ]; then
    echo "Installed"
else
    echo "Nope"
fi

if [ brew search c-blosc 2>&1 >/dev/null ]; then
    echo "Installed"
else
    echo "Nope"
fi

Nope即使我安装了它也打印

标签: bashcommand-linehomebrew

解决方案


根据https://apple.stackexchange.com/q/145437,您可以这样做

brew info c-blosc

除其他外,这将打印安装位置。您可以使用相关命令,例如search

brew search c-blosc

唯一明确记录为缺少公式返回失败代码的命令是

brew --prefix --installed c-blosc

它没有专门的输出,所以你可以做

if brew --prefix --installed c-blosc 2>/dev/null; then
    echo "Installed"
else
    echo "Nope"
fi

推荐阅读