Skip to content
Advertisement

How to split a number in a filename in Linux? [closed]

I have this file name:

 ABCD1B02.C50.N1995009.2019353.dat

I would like to extract the final 7 numbers and put space like this

       extr=2019 353;

Advertisement

Answer

In bash script:

fname='ABCD1B02.C50.N1995009.2019353.dat'
extr="${fname:${#fname}-11:4} ${fname:${#fname}-7:3}"
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement