getting info from plutil

10,476

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

Share:
10,476
Lewis Denny
Author by

Lewis Denny

Updated on July 22, 2022

Comments

  • Lewis Denny
    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 option plutil -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
    MikeBeaton about 8 years
    I guess this must be a different version, it has a -show flag in the OP's question as well.
  • MikeBeaton
    MikeBeaton almost 8 years
    I think the 2>&1 trick in my answer above will make plutil output to stdout?