Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
cp_dmg() {
dmg="$1"
file="$2"
destination="$3"
mountpoint=$(hdiutil attach "$dmg" -nobrowse -plist|xpath '//key[.="mount-point"]/following-sibling::*[1]' 2> /dev/null|sed -e 's/<\/*string>//g')
cp "${mountpoint}/$file" "$destination"
hdiutil detach -quiet "$mountpoint"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment