<p>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</p>

<p><code>for file in *.vcf ; do bash indel_vcf_parasing.sh $file ; done</code></p>

CC BY-SA 4.0
2020-01-06T14:50:38.580Z
Can you provide some context to future readers about this answer
Bioathlete
CC BY-SA 4.0
2020-01-06T18:57:38.907Z
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
CC BY-SA 4.0
2020-01-07T15:08:16.980Z
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.
Bioathlete
CC BY-SA 4.0
2020-01-06T11:36:28.780Z
2020-01-07T15:28:39.057Z
2020-01-07T15:28:39.057Z
Zizogolu
<p>I have a bash script:</p>

<p>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 </p>

<p>I tried changes done in similar script in  <a href="https://bioinformatics.stackexchange.com/questions/11061/changing-this-code-in-a-way-to-work-for-my-files/11067?noredirect=1#comment15031_11067">Changing this code in a way to work for my files</a> but I just  messed everything up</p>

<vcf><bash><linux><wgs>
Looping over several files in bash
# Looping over several files in bash

(Asked by: username_0 on 2020-01-04)

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](https://bioinformatics.stackexchange.com/questions/11061/changing-this-code-in-a-way-to-work-for-my-files/11067?noredirect=1#comment15031_11067) but I just messed everything up

**Tags:** vcf, bash, linux, wgs

---

## 1 answers

### Answer by username_0 on 2020-01-06. Score: 2 | Accepted answer

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`

> **Comments:**
> **username_1**: Can you provide some context to future readers about this answer  
> **username_2**: 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.  
> **username_1**: 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.  

---

