Body: <p>I have used GATK script : <code>gatk IndexFeatureFile --input sampleid_hc.g.vcf</code> to create .idx files for individual vcf files. However I am trying to create a loop and submit as a slurm job to create .idx for 200 vcf files. The script I used for this is</p>
  <pre><code>for file in *.g.vcf; do ./gatk IndexFeatureFile -I ${file} -O ${file}.idx; done
  </code></pre>
  <p>When I do this, I keep getting an error saying bad substitution. Please assist.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-04-03T01:53:21.183Z
Comments.Text: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
Comments.UserDisplayName: Community
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-04-03T04:41:12.400Z
Comments.Text: If you're running an older version of GATK you may need to specify the input using `-F` (re https://gatk.broadinstitute.org/hc/en-us/articles/360037428111-IndexFeatureFile) e.g. `for file in *.g.vcf; do ./gatk IndexFeatureFile -F "${file}" -O "${file}.idx"; done`. Also, is this the exact command you're running? Not `for f in *.g.vcf; do ... $file ...` or `for f in *.g.vcf.gz`? Might be worth adding in an `echo` before the command to make sure you are 'finding' the files you want to find (e.g. `for file in *.g.vcf; do echo "$file"; ./gatk IndexFeatureFile -I "${file}" -O "${file}.idx"; done`)
Comments.UserDisplayName: jared_mamrot
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-04-03T11:02:20.340Z
Comments.Text: What is the output of `ls *.g.vcf` in the directory you run the command from? Can your file names contain spaces? Does it work if you quote your variables correctly with `for file in *.g.vcf; do ./gatk IndexFeatureFile -I "$file" -O "$file".idx; done`? What is the _exact_ error you get?
Comments.UserDisplayName: terdon
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-04-21T01:24:48.497Z
Comments.Text: Thank you. I will try these suggestions
Comments.UserDisplayName: user20179
Tags: <vcf><gatk>
Title: Using GATK4.2 to create .idx using IndexFeatureFile for multiple vcf files
ThreadText: # Using GATK4.2 to create .idx using IndexFeatureFile for multiple vcf files
  
  (Asked by: username_0 on 2024-04-02)
  
  I have used GATK script : `gatk IndexFeatureFile --input sampleid_hc.g.vcf` to create .idx files for individual vcf files. However I am trying to create a loop and submit as a slurm job to create .idx for 200 vcf files. The script I used for this is
  
  ```
  for file in *.g.vcf; do ./gatk IndexFeatureFile -I ${file} -O ${file}.idx; done
  
  ```
  
  When I do this, I keep getting an error saying bad substitution. Please assist.
  
  **Tags:** vcf, gatk
  
  > **Comments:**
  > **username_1**: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.  
  > **username_2**: If you're running an older version of GATK you may need to specify the input using `-F` (re https://gatk.broadinstitute.org/hc/en-us/articles/360037428111-IndexFeatureFile) e.g. `for file in *.g.vcf; do ./gatk IndexFeatureFile -F "${file}" -O "${file}.idx"; done`. Also, is this the exact command you're running? Not `for f in *.g.vcf; do ... $file ...` or `for f in *.g.vcf.gz`? Might be worth adding in an `echo` before the command to make sure you are 'finding' the files you want to find (e.g. `for file in *.g.vcf; do echo "$file"; ./gatk IndexFeatureFile -I "${file}" -O "${file}.idx"; done`)  
  > **username_3**: What is the output of `ls *.g.vcf` in the directory you run the command from? Can your file names contain spaces? Does it work if you quote your variables correctly with `for file in *.g.vcf; do ./gatk IndexFeatureFile -I "$file" -O "$file".idx; done`? What is the _exact_ error you get?  
  > **username_0**: Thank you. I will try these suggestions  
  
  ---
  
  ## 0 answers
  
  