I have a directory with multiple files including .vcf files
I would like to loop the .vcf files but only take part of the filename. E.g. the filenames are
R1050C_v1_Non-Filtered.vcf
R1039B_v1_Non-Filtered.vcf
R1071D_v1_Non-Filtered.vcf
But the actual sample names are R1050C_v1, R1039B_v1, R1071D_v1
I know I can do something like:
for sample in *.vcf
do
something --input $sample --output ${i%_Non-Filtered.vcf}_someNewExtension.vcf
done
But I have several steps in the script and so ideally want to loop through just the sample names instead of then doing:
--input ${i%_Non-Filtered.vcf}_someNewExtension.vcf --output ${i%_Non-Filtered.vcf}_anotherNewExtension.vcf
I know I can also do:
for sample in *.vcf
do
echo "$sample" "${sample%_*}.vcf"
done
Which actually extracts the part that I want but is there a way of say instead of echo saving it into a new variable and then looping over this??