Skip to content

Instantly share code, notes, and snippets.

@putnamhill
putnamhill / hdiutil-attach-detach.sh
Last active April 3, 2025 09:15
Steps to attach a dmg disk image using hdiutil while capturing the mount point and dev entry for detaching when done
#!/bin/bash
dmg_path="$1"
# use process redirection to capture the mount point and dev entry
IFS=$'\n' read -rd '\n' mount_point dev_entry < <(
# mount the diskimage (leave out -readonly if making changes to the file system)
hdiutil attach -readonly -plist "$dmg_path" | \