Last Updated: March 18, 2017
·
280
· Lars Van Casteren

Pick a number, the highest number

Using Ansible I needed to find out the highest version number among a long list of jars all following a slightly different naming convention but all ending with the release number pattern, like namecomponentpossible-sub-component_additionaldata-02.004.043.jar.
This came in very handy:

for file in `ls -1`;do echo "$file"|tr -cd [:digit:];echo;done|sort -r|head -1