getting info from plutil
Solution 1
Oneliner which doesn't depend on extra utility to install:
plutil -extract CFBundleShortVersionString xml1 -o - ./Info.plist | sed -n "s/.*<string>\(.*\)<\/string>.*/\1/p"
Solution 2
If you need to test your .plist for the existence of the CFBundleShortVersionString
key, it's better to use PlistBuddy
like this:
/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" 1.plist || echo "CFBundleShortVersionString doesn't exist"
Solution 3
plutil -extract CFBundleShortVersionString xml1 -o - App-Info.plist
command prints out the content of CFBundleShortVersionString
property
Lewis Denny
Updated on July 22, 2022Comments
-
Lewis Denny almost 2 years
I'm having trouble direction info from plutil. I want to check if a .plist contains the key CFBundleShortVersionString. I don't think plutil has any option to test for if a key exists so I thought I would just
plutil -show file.plist >file.txt
but that just plain doesn't work. :/ So I tried to direct the plist file from stdout to file with the dump optionplutil -dump file.plist >file.txt
with no luck. :/ I also tried directing the stdout to stderr and stderr and stdout to file. Nothing worked. How do I do this? -
MikeBeaton about 8 yearsI guess this must be a different version, it has a -show flag in the OP's question as well.
-
MikeBeaton almost 8 yearsI think the
2>&1
trick in my answer above will makeplutil
output tostdout
?