Hi, I was hoping for help with a for loop to run a program (vina) repeatedly using all the files in a folder as input. Currently my code looks like this:
#!/bin/bash
FILES=/home/afalk/Desktop/battest/*.pdbqt
for f in $FILES do
vina --config /home/afalk/Desktop/A.txt --ligand "$f".pdbqt
done
vina simply runs as "vina" in the terminal and this code is my attempt at translating a working batch file I had for windows. Whenever I try to run this, and after endless changes to the syntax all I get is "line 4: syntax error near unexpected token `vina'". Can anyone see what I'm doing wrong?
You nearly had it! You didn't put a ; or newline before the 'do', though.
You don't need to put the filenames in a variable. That could actually be bad -- $FILES will split "file name.pdbgt file2.pdbgt" into "file", "name.pdbgt", "file2.pdbgt". "for FILE in *" won't.
You also don't need to put the ".pdbgt" back on the end, it never left
#!/bin/bash
for f in /home/afalk/Desktop/battest/*.pdbqt
do
vina --config /home/afalk/Desktop/A.txt --ligand "$f"
done
If it's in the current directory, you have to run it as ./vina
Otherwise, try whereis vina, that might tell you where it is. If it's in an odd location you'd run it as /path/to/vina
You don't want $vina, that's how you'd use a variable named vina. That must be blank, causing the line to become --config ... and of course it can't find any file to run named '--config' either.