Process hdiutil output with PlistBuddy

370 Views Asked by At

I'm trying to parse the output from hdiutil using PlistBuddy on the Mac terminal (without using a temporary file) and I'm running into some issues. I've tried the following:

Command 1

hdiutil info -plist | PlistBuddy -c "Print"

Output:

Prints the help for PlistBuddy


Command 2

PlistBuddy -c "Print" $(hdiutil info -plist)

Output:

File Doesn't Exist, Will Create: <?xml Invalid Arguments


I'm not great at bash but I think it might be an issue with PlistBuddy not accepting STDIN but only .plist files as input. Is there something that I'm missing or do I have to create a temporary file?

1

There are 1 best solutions below

0
Jief On BEST ANSWER

var=$(hdiutil info -plist)

PlistBuddy -c "Print" /dev/stdin <<< "$var"