Search code examples
regexsedgrepcut

How to get the release value?


I've a file with the below name formats:

rzp-QAQ_SA2-5.12.0.38-quality.zip
rzp-TEST-5.12.0.38-quality.zip
rzp-ASQ_TFC-5.12.0.38-quality.zip

I want the value as: 5.12.0.38-quality.zip from the above file names.

I'm trying as below, but not getting the correct value though:

echo "$fl_name" | sed 's#^[-[:alpha:]_[:digit:]]*##'

fl_name is the variable containing the file name.

Thanks a lot in advance!


Solution

  • It is much easier to use cut here:

    cut -d- -f3- file
    
    5.12.0.38-quality.zip
    5.12.0.38-quality.zip
    5.12.0.38-quality.zip
    

    If you want sed then use:

    sed -E 's/^([^-]*-){2}//' file
    
    5.12.0.38-quality.zip
    5.12.0.38-quality.zip
    5.12.0.38-quality.zip