I'm working on an uninstaller script to delete the parent folder where the script is installed.
/usr/local/Myapplication/Uninstaller/uninstall.sh
So uninstall.sh has to do this:
rm- rf /usr/local/Myapplication
I can retrieve the folder where uninstall resides
SYMLINKS=$(readlink -f "$0")
UNINSTALL_PATH=$(dirname "$SYMLINKS")
But I'm still unsure of the pretty way to get the parent path. I thought of using sed to demove the "Uninstaller" part of this path, but is there an elegant way to get the path to Myapplication folder to delete it?
Thank you
cd "$(dirname "$0")" && cd .. && cd .. && [ -d Myapplication/Uninstaller ] && rm -rf Myapplication
(I added a check that the directory we are about to delete contains a subdir "Uninstaller", but you could maybe add a better check, for example of a necessary file within Myapplication ?). If you don't know Myapplication, then :cd "$(dirname $0)" && cd .. && zepath="$(pwd)" && cd .. && [ -f "${zepath}/somefilesthathouldbehere" ] && rm -rf "${zepath}"
cd ..
from there.