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


2 Answers 2


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

  • $\begingroup$ Can you provide some context to future readers about this answer $\endgroup$
    – Bioathlete
    Jan 6, 2020 at 14:50
  • $\begingroup$ 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. $\endgroup$
    – Scot
    Jan 6, 2020 at 18:57
  • $\begingroup$ Please edit your answer to include the extra details so the answer is complete and a user doesn't have to read all the comments to understand. $\endgroup$
    – Bioathlete
    Jan 7, 2020 at 15:08

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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.