diff --git a/Software/SPSS Statistics/uninstall_SPSS.sh b/Software/SPSS Statistics/uninstall_SPSS.sh index b5bb270..433027b 100644 --- a/Software/SPSS Statistics/uninstall_SPSS.sh +++ b/Software/SPSS Statistics/uninstall_SPSS.sh @@ -1,9 +1,9 @@ -#! /bin/sh +#! /bin/bash ################################################################################################### # Script Name: uninstall_SPSS.sh # By: Zack Thompson / Created: 11/1/2017 -# Version: 1.1 / Updated: 1/18/2018 / By: ZT +# Version: 1.2 / Updated: 1/25/2018 / By: ZT # # Description: Remove previous version(s) of SPSS from /Applications # @@ -11,18 +11,24 @@ /bin/echo "***** Uninstall SPSS process: START *****" -# If the machine has multiple SPSS Applications, loop through them... -/usr/bin/find -E /Applications -iregex ".*[/](SPSS) ?(Statistics) ?(\d\d)?[.]app" -type d -prune | while IFS="\n" read -r appPath; do +/bin/echo "Searching for existing SPSS instances..." +appPaths=$(/usr/bin/find -E /Applications -iregex ".*[/](SPSS) ?(Statistics) ?([0-9]{2})?[.]app" -type d -prune) - # Get the App Bundle name - appName=$(/bin/echo $appPath | /usr/bin/awk -F "/" '{print $NF}') - # Get only the install path - installPath=$(/bin/echo $appPath | /usr/bin/awk -F "/$appName" '{print $1}') - # Delete the old version - /bin/echo "Uninstalling: ${appPath}" - /bin/rm -rf "${installPath}" - -done +# Verify that a SPSS version was found. +if [[ -z "${appPaths}" ]]; then + /bin/echo "Did not find an instance SPSS!" +else + # If the machine has multiple SPSS Applications, loop through them... + while IFS="\n" read -r appPath; do + # Get the App Bundle name + appName=$(/bin/echo $appPath | /usr/bin/awk -F "/" '{print $NF}') + # Get only the install path + installPath=$(/bin/echo $appPath | /usr/bin/awk -F "/$appName" '{print $1}') + # Delete the old version + /bin/echo "Uninstalling: ${appPath}" + /bin/rm -rf "${installPath}" + done < <(/bin/echo "${appPaths}") +fi /bin/echo "***** Uninstall SPSS process: COMPLETE *****"