I need to cut a portion of a string in linux

Posted by Abeed Salam on Stack Overflow See other posts from Stack Overflow or by Abeed Salam
Published on 2012-10-25T22:47:17Z Indexed on 2012/10/25 23:00 UTC
Read the original article Hit count: 164

Filed under:
|
|

I have a file in a folder like this:

installer-x86_64-XXX.XX-diagnostic.run

The XXX.XX is a version number and I need the version number only. How to do it in linux?

I have this code:

#!/bin/bash
current_ver=$(find /mnt/builds/current -name '*.run'|awk -F/ '{print $NF}')

So this gives me just the name of the file correctly (minus the location, which I dont want).

But how do I only get the XXX.XX version number into a variable such as $version

© Stack Overflow or respective owner

Related posts about linux

Related posts about string