From the error messages, it looks like it’s trying to run the script with the wrong Unix shell. (It should be bash, and the first line of the script says “run this in bash anyway” even if you try to run it in something else)
The fact that you got “command not found” messages on lines 2 6 and 13, but those are actually blank lines (which should be just ignored) might be a clue…
“Permission denied” trying to write to /dev/null might suggest you are actually running a restricted version of bash (for example rbash) not the real thing…
The message from line 18 suggests whatever shell you are running can’t understand the bash syntax for “if” statements.
If you type “which bash” or “file bash” in the console, does the output say “/bin/bash” or something else?
Another possibility would be that something strange happened when downloading the cleanup script. If you look at it in a text editor, does it lool exactly like this?
echo "Kill any existing VSTAudioEngine and Dorico processes"
echo "Remove preferences and application data"
rm ~/Library/Application\ Support/Steinberg/Dorico/preferences.xml 2>/dev/null
rm ~/Library/Application\ Support/Steinberg/Dorico/diagnosticsettings.ini 2>/dev/null
rm -fr ~/Library/Preferences/VSTAudioEngine
rm -fr ~/Library/Preferences/Dorico
rm -fr ~/Library/Caches/Dorico
if [ -d "$DORICOTMP" ]; then
echo "Removing temporary Dorico dir"
rm -fr "$DORICOTMP"
(Note: I’m not a Mac user but I have used plenty of different versions of Unix in my time)