I am trying to run some executable with parameters several times. I wrote a script for it. But I am always getting an error and can't figure out on how to fix it.


export VCF_FILE='KI_subsetted.recode.vcf'
for i in $(seq 22) do; /home/lab/Desktop/vcftools_0.1.13/bin/vcftools --vcf $VCF_FILE --chr i --out ./by_chrs_komi/i --recode; done

The error I am getting is:

./chrs.sh: line 3: syntax error near unexpected token `/home/lab/Desktop/vcftools_0.1.13/bin/vcftools'
./chrs.sh: line 3: `for i in $(seq 22) do; /home/lab/Desktop/vcftools_0.1.13/bin/vcftools --vcf ./KI_subsetted.recode.vcf --chr i --out ./by_chrs_komi/i --recode; done'

I am on the Ubuntu 15.10

  • you are saying --chr i, shouldn't it be --chr "$i"?
    – fedorqui
    Dec 11, 2015 at 14:27

1 Answer 1



for i in $(seq 22) ; do /home/aydar/Desktop/vcftools_0.1.13/bin/vcftools --vcf $VCF_FILE --chr $i --out ./by_chrs_komi/$i --recode; done
  • semicolon (;) before do
  • if $i is a number, no need for quotes.

or, programming style, and as per suggestion

for i in {1..22}
  /home/aydar/Desktop/vcftools_0.1.13/bin/vcftools \
    --vcf $VCF_FILE --chr $i --out ./by_chrs_komi/$i --recode
  • or for i in {1..22}, even better
    – fedorqui
    Dec 11, 2015 at 14:34
  • Thanks it worked. At least executable launches. However for some reason program cannot open the output file.
    – YKY
    Dec 11, 2015 at 14:48
  • Error: Could not open VCF Output file: ./by_chrs_komi/22.recode.vcf
    – YKY
    Dec 11, 2015 at 14:48
  • 1
    directory by_chrs_komi exists ? and is writable ?
    – Archemar
    Dec 11, 2015 at 15:09
  • 1
    is that by_chrs_komi (with s) or by_chr_komi (without) ?
    – Archemar
    Dec 11, 2015 at 15:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .