Batch remove substring from filename with special characters in BASH

前端 未结 2 508
渐次进展
渐次进展 2021-01-20 15:01

I have a list of files in my directory:

opencv_calib3d.so2410.so
opencv_contrib.so2410.so
opencv_core.so2410.so
opencv_features2d.so2410.so
opencv_flann.so24         


        
2条回答
  •  独厮守ぢ
    2021-01-20 15:41

    a='opencv_calib3d.so2410.so'
    echo "${a%%.so*}${a#*.so}"
    opencv_calib3d2410.so
    

    Where:

    • ${a%%.so*} - the part before the first .so
    • ${a#*.so} - the part after the first .so

提交回复
热议问题