Bash script to remove 'x' amount of characters the end of multiple filenames in a directory?

前端 未结 3 1877
我在风中等你
我在风中等你 2020-12-03 19:07

I have a list of file names in a directory (/path/to/local). I would like to remove a certain number of characters from all of those filenames.

3条回答
  •  一个人的身影
    2020-12-03 19:55

     mv $filname $(echo $filename | sed -e 's/.....\.moc1$//');
    

    or

     echo ${filename%%?????.moc1}.moc1
    

    %% is a bash internal operator...

提交回复
热议问题