Linux 批量删除文件后缀

时间:2022-05-05 02:12:00

例子:

[zengs@gene CASP9]$ ls
casp9.ids T0526 T0538 T0550 T0562 T0574 T0586 T0598 T0610 T0622 T0634
T0515 T0527 T0539 T0551 T0563 T0575 T0587 T0599 T0611 T0623 T0635
T0516 T0528 T0540 T0552 T0564 T0576 T0588 T0600 T0612 T0624 T0636
T0517 T0529 T0541 T0553 T0565 T0577 T0589 T0601 T0613 T0625 T0637
T0518 T0530 T0542 T0554 T0566 T0578 T0590 T0602 T0614 T0626 T0638
T0519 T0531 T0543 T0555 T0567 T0579 T0591 T0603 T0615 T0627 T0639
T0520 T0532 T0544 T0556 T0568 T0580 T0592 T0604 T0616 T0628 T0640
T0521 T0533 T0545 T0557 T0569 T0581 T0593 T0605 T0617 T0629 T0641
T0522 T0534 T0546 T0558 T0570 T0582 T0594 T0606 T0618 T0630 T0642
T0523 T0535 T0547 T0559 T0571 T0583 T0595 T0607 T0619 T0631 T0643
T0524 T0536 T0548 T0560 T0572 T0584 T0596 T0608 T0620 T0632
T0525 T0537 T0549 T0561 T0573 T0585 T0597 T0609 T0621 T0633
[zengs@gene CASP9]$ pwd
/u1/home/zengs/Downloads/CASPALL/CASP9/

删除CASP9 目录下所有所有目录下带.pdb后缀的文件后缀

/u1/home/zengs/Downloads/CASPALL/CASP9/T0525/MUFOLD-Server-TS1.pdb

--->

/u1/home/zengs/Downloads/CASPALL/CASP9/T0525/MUFOLD-Server-TS1

 for j in *; do for i in $(find $j/*.pdb); do mv $i  ${i%.*}; done;done;