I get this unexpected 'done' token error
echo -e "Enter the file stem name"
read filestem
for i in {1..22}
do
`java -cp /export/home/alun/jpsgcs/ CMorgansToTheta $filestem_$i.INPUT.par $filestem_$i.THETA.par`
done
If the Java program writes nothing to output, your for loop is equivalent (because of the backquotes) to
for i in {1..22}
do
done
which produces the error you see. It's likely you simply want to remove the backquotes to run the program 22 time:
echo -e "Enter the file stem name"
read filestem
for i in {1..22}
do
java -cp /export/home/alun/jpsgcs/ CMorgansToTheta "${filestem}_$i.INPUT.par" "${filestem}_$i.THETA.par"
done
In your Java command line:
java -cp /export/home/alun/jpsgcs/ CMorgansToTheta $filestem_$i.INPUT.par $filestem_$i.THETA.par
You are using:
$filestem_$i
Which will be equivalent to:
${filestem_}${i}
because underscore _ is not considered a word boundary in shell and whole filestem_ will be considered variable name. Most likely you should be using:
${filestem}_${i}
Can you show me output of this script?
#!/bin/bash
set -x
echo -e "Enter the file stem name"
read filestem
for i in {1..3}
do
echo "java -cp /export/home/alun/jpsgcs/ CMorgansToTheta ${filestem}_${i}.INPUT.par ${filestem}_${i}.THETA.par"
done
#!/bin/bashheader to the top of the script?java -cp ..in backticks? Doesn't make sense, unless you're getting output of the java command to some variable.bashstatements?