Example data:
cat lookup.tsv
SRR7015874_1.fastq
SRR7015874_2.fastq
SRR7015875_1.fastq
SRR7015875_2.fastq
SRR7015876_1.fastq
SRR7015876_2.fastq
SRR7015877_1.fastq
SRR7015877_2.fastq
Using this command:
awk '{print $1 "\t" "SRR\_" NR ".fastq"}' lookup.tsv > lookup_table.tsv
I get two columns:
SRR7015874_1.fastq SRR_1.fastq
SRR7015874_2.fastq SRR_2.fastq
SRR7015875_1.fastq SRR_3.fastq
SRR7015875_2.fastq SRR_4.fastq
SRR7015876_1.fastq SRR_5.fastq
SRR7015876_2.fastq SRR_6.fastq
SRR7015877_1.fastq SRR_7.fastq
SRR7015877_2.fastq SRR_8.fastq
Now I want to create third column, like this:
SRR1_1.fastq
SRR1_2.fastq
SRR2_1.fastq
SRR2_2.fastq
SRR3_1.fastq
SRR3_2.fastq
SRR4_1.fastq
SRR4_2.fastq
And I want to use the second and third columns to rename files (i.e. if the filename = $2, change it to $3)
I tried:
cat lookup_table.tsv | while read c1 c2; do mv $c1 $c2 ; done
SRR1_1.fastq
SRR1_2.fastq
SRR2_1.fastq
SRR2_2.fastq
SRR3_1.fastq
SRR3_2.fastq
But this was not successful. Is there an error in my code/approach?