Detect if homebrew package is installed

前端 未结 4 1053
梦如初夏
梦如初夏 2021-01-30 04:42

I\'m about to write a shell script to detect if several homebrew packages are installed in the system. Is there a way to use a brew command to achieve that?

I tried usin

4条回答
  •  臣服心动
    2021-01-30 05:40

    What about?

    for pkg in macvim ngrep other needed packages; do
        if brew list -1 | grep -q "^${pkg}\$"; then
            echo "Package '$pkg' is installed"
        else
            echo "Package '$pkg' is not installed"
        fi
    done
    

提交回复
热议问题