![The image shows different versions of TR - I want to delete, without deleting any other applications and keeping the latest version of TR 2091.2](https://i.stack.imgur.com/gtjNQ.png)

I want to remove all previous versions of Tableau Reader.app from applications apart from the latest one. I want to do this through command line. The problem that I am having is I want to remove all files containing `tableau reader` except for the file `tableau reader 2019.2`.

I have tried multiple ways but they aren't working. I am not very experienced with this. Any help is appreciated. The script below: Checks if the Application is running and if not goes about deleting the different versions(bit I need help on) 

```
#!/bin/bash
shopt -s extglob

process="$4"
processrunning=$( ps axc | grep "${process}" )

if [ "$processrunning" != "" ] ; then

echo "$process IS running, do nothing" 
echo "error: script failed"

exit 1
else 

echo "$process is not running and will remove the old versions"

find $HOME/Applications/ -type f -not -name 'Tableau Reader 2019.2.app' | grep "tableau reader" | xargs rm

#rm -r $HOME/Applications/Tableau Reader?*.app![$HOME/Applications/"Tableau Reader 2019.2.app"]

#find. -type f !( -name 'Tableau Reader 2019.2.app') -exec rm -f "Tableau Reader"*.app {} +

fi

```