I'm not looking for some nightly releases, I just want the highest version of software available in apt's database. Although a beginner, I managed to pull just a list of basic tomcat installations:XXXXX@debianvirtualbox:~/$ aptitude search tomcat[0-9]+$p   tomcat7                         - Servlet and JSP engine                    i   tomcat8                         - Apache Tomcat 8 - Servlet and JSP engineSame can be done for other programs too, but I have not found any other that would host 2 different versions with otherwise same name. I assume one day tomcat0 will pop out and I'd rather not edit my installer just to ensure we're up to latest version.So is there a way to extend my command in such a way that it will find highest if tomcat[0-9]+ matches which will them be used for apt-get install, like this?TOMCAT=getLatestTomcat; # I need your help with this lineread -p Tomcat server is missing. Install $TOMCAT server automatically? -n 1 -recho if [[ $REPLY =~ ^[Yy]$ ]]then   echo Ok, installing.;   apt-get install $TOMCATelse   echo Ok, do it yourself...   exit 404;fi;It would be great if the answer was more generic, as it may be more useful in further applications than the script I'm just doing.
Install latest version of number-versioned software like Tomcat using apt-get?
bash;aptitude
You can just use sort for this. Here is an example:getLatestTomcat() {  apt-cache search 'tomcat[0-9]+$' | awk '{ print $1 }' | sort --version-sort | tail -n 1}tomcat_package=$(getLatestTomcat)