Created
August 12, 2014 12:23
-
-
Save jacobsalmela/2ecc8fd3610bd6f87904 to your computer and use it in GitHub Desktop.
(OS X) Fast version check of Apps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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