How can I just extract one underbar-separated field from a filename?

后端 未结 1 1741
一向
一向 2021-01-27 17:55

I have a list of file names like this:

REG_2016120200hourly_d01_20161202_00_00_00.nc

Of this name I would like to extract and put in a variable:

相关标签:
1条回答
  • 2021-01-27 18:07
    timestep="${filename:34:2}"
    

    2 is length.


    From man bash:

    ${parameter:offset:length}: Substring Expansion. Expands to up to length characters of the value of parameter starting at the character specified by offset. [...]

    0 讨论(0)
提交回复
热议问题