[root@nfsC test]# ll
total 8
-rw-r--r-- 1 root root 73 Mar 22 10:53 1.sh
-rw-r--r-- 1 root root 130 Mar 22 10:54 f
-rw-r--r-- 1 root root 0 Mar 22 11:03 stu_102999_1_finished.jpg
-rw-r--r-- 1 root root 0 Mar 22 11:03 stu_102999_2_finished.jpg
-rw-r--r-- 1 root root 0 Mar 22 11:03 stu_102999_3_finished.jpg
-rw-r--r-- 1 root root 0 Mar 22 11:03 stu_102999_4_finished.jpg
-rw-r--r-- 1 root root 0 Mar 22 11:03 stu_102999_5_finished.jpg
法1
[root@nfsC test]# ls *.jpg|sed -r 's#(^.*)_finished.*$#mv & \1.jpg#g'|bash
[root@nfsC test]# ll
total 8
-rw-r--r-- 1 root root 73 Mar 22 10:53 1.sh
-rw-r--r-- 1 root root 130 Mar 22 10:54 f
-rw-r--r-- 1 root root 0 Mar 22 11:03 stu_102999_1.jpg
-rw-r--r-- 1 root root 0 Mar 22 11:03 stu_102999_2.jpg
-rw-r--r-- 1 root root 0 Mar 22 11:03 stu_102999_3.jpg
-rw-r--r-- 1 root root 0 Mar 22 11:03 stu_102999_4.jpg
-rw-r--r-- 1 root root 0 Mar 22 11:03 stu_102999_5.jpg
[root@nfsC test]#
法2
[root@nfsC test]# ls *.jpg |awk -F "_finished" '{print "mv " $0,$1$2}'|bash
法3
[root@nfsC test]# cat 1.sh
for f in `ls *finish*.jpg`
do
mv $f `echo $f|sed 's#_finished##g'`
done
[root@nfsC test]#
法4
[root@nfsC test]# rename "_finished" "" *.jpg
[root@nfsC test]# ll
total 8
-rw-r--r-- 1 root root 73 Mar 22 10:53 1.sh
-rw-r--r-- 1 root root 130 Mar 22 10:54 f
-rw-r--r-- 1 root root 0 Mar 22 11:17 stu_102999_1.jpg
-rw-r--r-- 1 root root 0 Mar 22 11:17 stu_102999_2.jpg
-rw-r--r-- 1 root root 0 Mar 22 11:17 stu_102999_3.jpg
-rw-r--r-- 1 root root 0 Mar 22 11:17 stu_102999_4.jpg
-rw-r--r-- 1 root root 0 Mar 22 11:17 stu_102999_5.jpg
[root@nfsC test]#