在Linux上,如何将文件名从blah_m_n_12192012.txt更改为blah_m_n.txt

时间:2021-02-06 18:55:28

where m, n could be any number from 0 to 100, for example

例如,其中m,n可以是0到100之间的任何数字

blah_5_9_12192012.txt -> blah_5_9.txt
blah_4_35_12192012.txt -> blah_4_35.txt

I tried doing the following but it didn't work

我尝试了以下但是没有用

mv blah_?_*_12192012.txt blah_?_*.txt

1 个解决方案

#1


1  

for file in blah_?_*_12192012.txt
do
  mv $file ${file/_12192012/}
done

#1


1  

for file in blah_?_*_12192012.txt
do
  mv $file ${file/_12192012/}
done