0

I have a bash workflow that run some functions provided in the same code according to the number of the desired repetitions (defined as rep).

rep='4'
# run functions REP times
for i in $(seq 1 $rep); do
png_summary
hbond_summary
hbond_total_summary 
done

I noticed that sometimes this does not work:

./vizu_ultimo.sh: line 384: syntax error near unexpected token `do'
./vizu_ultimo.sh: line 384: `(seq 1 $rep); do'

Since this eror occurs relatively rare I have not been able to understand what's wrong with the code ..

  • 2
    "this eror occurs relatively rare" Nah, thats not how bash works. Maybe one of the command inside the loops throws an error. I'd start by defining `rep` as an integer. – 0stone0 Mar 09 '22 at 10:00
  • my example fits to the method described in that topic: for i in $(seq $count); do ........ so no it does not help me, – Maître Renard Mar 09 '22 at 10:03
  • Is `rep` defined in some other way than `rep=4`? Is the script sourcing some other code conditionally? – Fravadona Mar 09 '22 at 10:21
  • There is no sourcing. the variable is defined as rep='4' (with single quotes. is the difference with rep=4 (without any quotes) ? I've never seen the problems with other variables due to this .. – Maître Renard Mar 09 '22 at 10:25
  • 1
    Your problem is not reproducible. A common beginner error is having DOS line feeds in your script file; though when I try that on my Mac, I get `seq: invalid floating point argument: 4'\r` and the same on Ubuntu – tripleee Mar 09 '22 at 13:39

0 Answers0