$ rename -n 's/_[ATGC]*-[ATGC]*//' *.gz
'VIR3A_CCGCGGTT-CTAGCGCT_L00M_R1_001.fastq.gz' would be renamed to 'VIR3A_L00M_R1_001.fastq.gz'
'VIR3Q_TAATACAG-GTGAATAT_L00M_R2_001.fastq.gz' would be renamed to 'VIR3Q_L00M_R2_001.fastq.gz'
'VIR4J_CGTTAGAA-GACCTGAA_L00M_R1_001.fastq.gz' would be renamed to 'VIR4J_L00M_R1_001.fastq.gz'
Remove dry-run if you are okay with output from dry run.
in bash shell (and sed):
$ for i in *.gz; do output=$(echo $i| sed 's/_[ATGC]*-[ATGC]*//'); echo cp $i $output; done
cp VIR3A_CCGCGGTT-CTAGCGCT_L00M_R1_001.fastq.gz VIR3A_L00M_R1_001.fastq.gz
cp VIR3Q_TAATACAG-GTGAATAT_L00M_R2_001.fastq.gz VIR3Q_L00M_R2_001.fastq.gz
cp VIR4J_CGTTAGAA-GACCTGAA_L00M_R1_001.fastq.gz VIR4J_L00M_R1_001.fastq.gz
why is it an issue ?
I'm trying to change the file names to the mentioned desired ones, there are like 40 of the files with the same pattern of ACTG elements