Install dmg package on MAC OS from Terminal

后端 未结 4 1090
孤独总比滥情好
孤独总比滥情好 2021-02-09 01:33

I would like to install the dmg java package in my MAC OS through the terminal

I tried using this command:

sudo installer -package jdk-7u51-macos-x64.dmg         


        
4条回答
  •  醉话见心
    2021-02-09 02:27

    Let dmgFilePath be the variable containing the path of your dmg file.

    Then you can try this :

    $ MOUNTDEV=$(hdiutil mount $dmgFilePath | awk '/dev.disk/{print$1}')
    $ MOUNTDIR="$(mount | grep $MOUNTDEV | awk '{$1=$2="";sub(" [(].*","");sub("^  ","");print}')"
    $ sudo installer -pkg "${MOUNTDIR}/"*.pkg -target /
    $ hdiutil unmount "$MOUNTDIR"
    

    Tested on macOS High Sierra even if "$MOUNTDIR" contains one space.

提交回复
热议问题