-2

I have several files in a direcotry such as :

BUSCO_Canis_lupus_BUSCO_v3_451441870_exon_probs.pbl
BUSCO_Canis_lupus_BUSCO_v3_45144182_metapars.cgp.cfg
BUSCO_Canis_lupus_BUSCO_v3_451441E0_weightmatrix.txt
BUSCO_Canis_lupus_BUSCO_v3_451441D0_parameters.cfg

and I would like to rename these file by removing the BUSCO_ part at the begenning and the _BUSCO_v3_Number_ part in the middle to get :

Canis_lupus_exon_probs.pbl
Canis_lupus_metapars.cgp.cfg
Canis_lupus_weightmatrix.txt
Canis_lupus_parameters.cfg

I know how to use sed and mv but not how to combine both.

chippycentra
  • 3,396
  • 1
  • 6
  • 24
  • see https://mywiki.wooledge.org/CommandSubstitution – Sundeep Jun 29 '20 at 13:31
  • See also: https://stackoverflow.com/questions/2372719/using-sed-to-mass-rename-files and https://stackoverflow.com/questions/5671773/rename-files-using-sed-and-mv – Sundeep Jun 29 '20 at 13:36

1 Answers1

1

With perl rename:

rename -n 's/(?:^BUSCO_|_BUSCO_v3_\d+)//g' *BUSCO*

Remove -n switch when the output looks good

Gilles Quénot
  • 173,512
  • 41
  • 224
  • 223