# Looping over several files in bash

I have a bash script:

I am wondering how I can change this script to loop over a bunch of .vcf files and give output .txt with the name of corresponding .vcf

I tried changes done in similar script in Changing this code in a way to work for my files but I just messed everything up

If we save the script pasted in the main post as a sh file and we have some .vcf files in a folder, by this line we can iterate over vcf files to extract what mentioned in the script returning .txt output by the name of corresponding vcf

for file in *.vcf ; do bash indel_vcf_parasing.sh \$file ; done

• This is generally the method I use for scaling. Write a program to do 'one', then write wrappers, or use one-liners (as this answer shows) to do many. You will need to be sure that successive runs do not step on each other (if using a single directory for all runs), or make a new directory for each run if necessary.
– Scot
Jan 6 '20 at 18:57

Error means that quotations are missing. I am not going to review this chunk but at first glance check

printf 'TumorAltAlleleCount\tTumorAltAlleleFrequency\t'\n'


There are three quotation marks so one is not matched. I suggest you develop code within a good IDE that will help you debug. Please google around for potential solutions. I personally do R and Shell scripting in RStudio. It differently colors quoted and unquoted code so you immediately see if you missed a closing quotation somewhere.