while循环语法错误意外结束文件

do *_*kim 0 syntax bash syntax-error while-loop

我的while循环有语法错误,我的代码如下

#! /bin/bash
# extracts pdb from mdcrd and fix number and move to one central location

filename="min_8a-"
i=1
num_structures=1000
natoms=97
folders=15



while [[ $i -le $folders ]]; do
 cd ~/new/sa/na-main/a-na-main/second/$i
 mkdir pdbfit

x=1

 while [[ $x -le $num_structures ]]; do

   ptraj ./8a-${a}.prmtop << EOF
   trajin $filename$a.mdcrd $x $x 1
   trajout pdbfit/a-2-$i.pdb pdb dumpq
 EOF
 let x=$x+1
 done

 cd pdbfit 
 mv *.* ~/pdbfit
 cd ..
 rm pdbfit

let i=$i+1
done
Run Code Online (Sandbox Code Playgroud)

我得到第34行语法错误,指出"语法错误:意外的文件结束"

作为一个未经训练的眼睛,我尝试但未能解决这个问题,所以如果有人可以帮助我,那么这将是伟大的.

Mat*_*Mat 5

确保EOF在行的开头.

   ptraj ./8a-${a}.prmtop << EOF
   trajin $filename$a.mdcrd $x $x 1
   trajout pdbfit/a-2-$i.pdb pdb dumpq
EOF
^ no space before the E
Run Code Online (Sandbox Code Playgroud)