- #1
Animastryfe
- 81
- 0
Edit: Why did my thread title change?
I have never used bash before. I'm trying to make a script that will execute the program new3body while changing 'A' and 'i'. I want the script to run the program for A=0 to A=8.9 while COUNTER=-4.5, then do the same thing again for COUNTER=-4.4, all the way to COUNTER=6. When I tried to run this script, the following error popped up:
I have heard that bash doesn't like to work with non-integers, and I used 'bc' at the end of the program from a google search earlier, but I don't understand how it works. Also, the variable "B" is there solely to act as a counter for "A", because '-lt' doesn't work with floating point numbers.
I also tried this variant, using the same work-around as I used for 'A'. 'COUNTER' is now 'D'.
The error this time is
Code:
#!/bin/bash
A=0
B=0
while [ $B -lt 90 ]
do
for (( COUNTER=-4.5; COUNTER<=6; COUNTER+=0.1 ));
do
./new3body $A $COUNTER 2 > outangle$A-$COUNTER 2>&1
done
B=`echo "$B+1." |bc -l`
A=`echo "$A+0.1" |bc -l`
done
I have never used bash before. I'm trying to make a script that will execute the program new3body while changing 'A' and 'i'. I want the script to run the program for A=0 to A=8.9 while COUNTER=-4.5, then do the same thing again for COUNTER=-4.4, all the way to COUNTER=6. When I tried to run this script, the following error popped up:
Code:
./bashangle: line 6: ((: COUNTER=-4.5: syntax error: invalid arithmetic operator (error token is ".5")
I also tried this variant, using the same work-around as I used for 'A'. 'COUNTER' is now 'D'.
Code:
#!/bin/bash
A=0
B=0
while [ $B -lt 90 ]
do
C=0
while [ $C -lt 105 ]
D=0
do
./new3body $A $D 2 > outangle$A-$D 2>&1
C='echo "$C+1." |bc -l'
D='echo "$D+0.1" |bc -l'
done
B=`echo "$B+1." |bc -l`
A=`echo "$A+0.1" |bc -l`
done
The error this time is
Code:
./bashangle: line 7: [: too many arguments
Last edited: