我的目录有很多名为“20130101_temp.txt”,“20130102_temp.txt”等的文件.
@H_404_6@
使用bash:
如何删除所有这些文件的名称中的“_temp”.即,将20130101_temp.txt重命名为20130101.txt.
for x in *_temp.txt do mv $x ${x%%_temp.txt}.txt done
Perl(至少在Ubuntu上)还有一个名为rename的实用程序,它采用正则表达式,所以你可以用以下方法完成同样的事情:
rename -n 's/_temp\.txt$/.txt/' *_temp.txt