I have the following array
components=('xx' 'xy' 'xz' 'yx''yy''yz''zx''zy''zz')
And I'm doing the following loop for all components
for i in "${components[@]}"
do
if [ ${i: -1} == "x" ]; then
awk '$1 == "*" && $2 == ${i: -1} {v=$3} END {print v}' ${i}_E_cutoff_$((100*$a))_eV/$systemID.castep >> Stress_${i}_vs_Ecutoff_convergence.txt
elif [ ${i: -1} == "y" ]; then
awk '$1 == "*" && $2 == ${i: -1} {v=$4} END {print v}' ${i}_E_cutoff_$((100*$a))_eV/$systemID.castep >> Stress_${i}_vs_Ecutoff_convergence.txt
elif [ ${i: -1} == "z" ]; then
awk '$1 == "*" && $2 == ${i: -1} {v=$5} END {print v}' ${i}_E_cutoff_$((100*$a))_eV/$systemID.castep >> Stress_${i}_vs_Ecutoff_convergence.txt
fi
done
How come awk tells me I have a syntax error for
$2 == ${i: -1}