LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   incrementing variable in an until loop (https://www.linuxquestions.org/questions/programming-9/incrementing-variable-in-an-until-loop-322701/)

jeffreybluml 05-12-2005 07:36 AM

incrementing variable in an until loop
 
What's wrong with this?

Code:

x=1;
until $x=30;
do
grep blah blah blah blah blah...;
sed blah blah blah blah;
x=$x+1;
done;

Becuase this is what I get...

Code:

/bin/getphone: line 6: 1=30: command not found
/bin/getphone: line 6: 1+1=30: command not found
/bin/getphone: line 6: 1+1+1=30: command not found
/bin/getphone: line 6: 1+1+1+1=30: command not found
/bin/getphone: line 6: 1+1+1+1+1=30: command not found
/bin/getphone: line 6: 1+1+1+1+1+1=30: command not found
/bin/getphone: line 6: 1+1+1+1+1+1+1=30: command not found

I'm trying to fix a "script" from another thread, and I can't figure out how to run the commands within the loop 30 times and stop and exit...

Greatly appreciate any assistance...

Jeff

trevelluk 05-12-2005 07:41 AM

You need to use let to do arithmetic in bash:

let "x = $x + 1"

That "until" syntax doesn't look right either. Try until [ $x -eq 30 ]; do

jeffreybluml 05-12-2005 07:45 AM

Excellent!

Thank you!!

Now for the next problem....new thread...


All times are GMT -5. The time now is 05:51 AM.