I was initially attempting to do this in Java using the UserDefinedFileAttributeView class but it turns out that is only available on Windows computers (This is being run on OSX)

So I switched gears with the hope that retrieving the information via a script would be the simpler route but it seems to not be as straight forward as I expected.

How would one go about retrieving an Application file's version number (file attribute) using Bash?

I've already looked into stat but that only returns the basic file information. I also looked into xattr but I couldn't get that to return the "Version" attribute.

Any pointers would be greatly appreciated!

  • 2
    Where do you think this information is being stored? Please post an example.
    – CodeGnome
    Dec 25, 2015 at 3:00
  • 1
    Your Q lacks detail. Have your read, understood, and tried to write an appropriate "MCVE" -> stackoverflow.com/help/mcve ? Good luck.
    – shellter
    Dec 25, 2015 at 3:02
  • To add to other comments, it's difficult to answer the question as asked, the best thing to do would be take a step back and state why you are trying to do what you're trying to do.
    – Julian
    Dec 25, 2015 at 3:08
  • @CodeGnome The version number is easily seen by right clicking a file in OS X and viewing its "info" not sure how much more detail is needed. I'm that familiar with Bash scripting and I am wondering if there is a way to retrieve this value via a Bash script. Dec 25, 2015 at 3:11

4 Answers 4


If you want to get the Version of an Application, which is what's shown in the Finder Get Info dialog box, then use this:

plutil -p /Applications/<Application Name>.app/Contents/Info.plist | grep CFBundleShortVersionString

This will show you the version information.

For more information see this answer.

  • Thank you this also worked perfectly. I also posted an alternative below. Dec 25, 2015 at 3:51
  • 1
    Thank you, for the benefit of anybody coming across this question I'd suggest updating the question to clarify you're not trying to get the version of a file from the filesystem but the version of an OSX application. If you look at the finder info for an arbitrary file on the filesystem you'll see that it doesn't have a version.
    – Julian
    Dec 25, 2015 at 4:02
  • I've updated my question appropriately. I wasn't familiar with the version attribute but I know see what you are saying. It was an oversight on my part Dec 25, 2015 at 4:14
  • The "-p" argument to plutil is not valid for some older versions of OS X. You can accomplish the same thing with /usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" /Applications/<APPLICATION NAME>.app/Contents/Info.plist, which will just print the value without the need to grep anything.
    – Kent
    Jan 4, 2016 at 23:52

You can use defaults to fetch specific keys:

VERSION=$(defaults read /Applications/AppName.app/Contents/Info.plist CFBundleShortVersionString)

I kept digging around and it looks like one possible solution is to use mdls , with the attribute 'kMDItemVersion'.


Applications: user$ mdls -name kMDItemVersion Xcode.app
kMDItemVersion = "7.2"

If anyone else needs this the documentation is here: mdls


Generally Linux does not support a file version attribute. However you can use mimetype utility to access file extension and type...


mimetype -d path_to_my_file
  • I am referring to the "Version" tag not File Versioning it self. Dec 25, 2015 at 3:22
  • Linux doesn't have that...linux is a little different from WIndows...I have been using linux for years now..I am not aware of that..my apologies...
    – repzero
    Dec 25, 2015 at 3:25
  • He's asking about OSX (as per the parenthetical remark in the first paragraph).
    – Julian
    Dec 25, 2015 at 3:36
  • have you tried the mimetype utility in linux?..I have explored some of the basic parameter arguments but no luck....
    – repzero
    Dec 25, 2015 at 3:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .