I would like to write multiple lines to a file with the EOT, but the following script
#!/bin/bash
bench="X"
file_name="submit2.sh"
ids=(55)
for id in "${arrayName[@]}"; do
cat <<'EOT' >> $bench/$file_name
#!/bin/bash -l
#PBS -l nodes=1:ppn=1
echo $id
EOT
done # line 11
Gives this error
line 11: warning: here-document at line 6 delimited by end-of-file (wanted `EOT')
line 12: syntax error: unexpected end of file
How can I fix that?
ids=(55)
just sets the variable$id
to the string55
; ii)for id in "${arrayName[@]}"; do
will fail since you don't definearrayName
anywhere; iii) even if that did work, you would still always be writing toX/submit2.sh
, since the values of$bench
and$file_name
never change. – terdon Sep 13 '22 at 15:03