I am trying to get the mounted size of a compressed .dmg. I can use hdiutil imageinfo -plist $imagename to get a lot of info, including what I need. The problem is that I have no idea how to parse that single piece of info into a variable (or in this case, array element). Here is what I have so far
#!/bin/bash
#first part of script which generates the array below
for i in ${DMGLIST[@]} #This array contains a list of .dmg files
do
hdiutil imageinfo -plist $i | #some way to parse stdout for the info and save it to a variable
done
The info I need is in the middle of the output
<key>Total Bytes</key>
<integer>73400320</integer>
And I have no idea how to go about parsing through it since the string is broken up by the </key> and <integer> things. I can think of some complex, inelegant ways, but I'm sure someone here has an idea for how to do it better! Thanks!