Unix cut except last two tokens

后端 未结 4 1373
执念已碎
执念已碎 2021-02-18 19:54

I\'m trying to parse file names in specific directory. Filenames are of format:

token1_token2_token3_token(N-1)_token(N).sh

I need to cut the t

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-18 20:35

    It can not be done with cut, How ever you can use sed or awk

    sed -r 's/(_[^_]+){2}$//g'
    

提交回复
热议问题