Skip to content

Instantly share code, notes, and snippets.

@talkingmoose
Created April 10, 2020 18:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save talkingmoose/0cefc38d6b835167f5db95231e0050e9 to your computer and use it in GitHub Desktop.
Save talkingmoose/0cefc38d6b835167f5db95231e0050e9 to your computer and use it in GitHub Desktop.
Returns the installation date for an app installed uisng an Apple Installer package. In Terminal run /path/to/script /path/to/Bundle.app (drag the app into the window).
#!/bin/bash
# in Terminal run /path/to/script /path/to/Bundle.app
installedApp=$1
# get the app's bundle identifier
bundleID=$( /usr/bin/defaults read "$installedApp/Contents/Info.plist" CFBundleIdentifier )
# get the installation epoch date for the bundle identifier
installEpoch=$( /usr/sbin/pkgutil --pkg-info="$bundleID" | /usr/bin/grep "install-time" | /usr/bin/awk '{ print $2 }' )
# convert epoch date to user-readable date and return the result
echo Installed: $( /bin/date -j -f "%s" "$installEpoch" )
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment