Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jacobsalmela/2ecc8fd3610bd6f87904 to your computer and use it in GitHub Desktop.
Save jacobsalmela/2ecc8fd3610bd6f87904 to your computer and use it in GitHub Desktop.
(OS X) Fast version check of Apps
#!/bin/bash
#----------AUTHOR------------
# Jacob Salmela
# 24 May 2013
#----------RESOURCES---------
# http://stackoverflow.com/questions/4128235/bash-shell-scripting-what-is-the-exact-meaning-of-ifs-n
#---------DESCRIPTION--------
# Attempts to list all apps in /Applications and their version numbers
#----------VARIABLES---------
# Avoid trailing newlines so apps with spaces in their names still appear on one line
IFS=$'\n'
#----------FUNCTIONS---------
##########################
function listAppVersions()
{
# For each .app in ./Applications
for i in $(find /Applications -type d -name "*.app" -maxdepth 1)
do
# echo the app name
echo "$i" | cut -d'/' -f3-
# Read the version number and send errors to the Sarlaac Pit
defaults read "$i"/Contents/version CFBundleShortVersionString 2>/dev/null
# If the version.plist does not exist, check the Info.plist and send errors to the Sarlaac Pit
if [ $? -ne 0 ];then
defaults read "$i"/Contents/Info CFBundleShortVersionString 2>/dev/null
fi
done
}
#---------------------------------
#----------BEGIN SCRIPT-----------
#---------------------------------
listAppVersions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment