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
Written by Lars Van Casteren
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Related Tags
#bash
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#