简体   繁体   中英

Updating brew package in bash script on OSX

I'm working on a bash script that depends on specific package. This script will be used globally, on different machines. Some of them will have it, and some not.

How could I verify, as part of the bash script, if package is installed and to update/install it if needed?

My package manager (OSX 10.12) is brew .

You could write sth like:

#!/bin/bash

if brew ls --versions the_package_name > /dev/null; then
    # whatever you want to do
else
    brew install the_package_name
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM