LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-12-2005, 07:36 AM   #1
jeffreybluml
Member
 
Registered: Mar 2004
Location: Minnesota
Distribution: Fedora Core 1, Mandrake 10
Posts: 405

Rep: Reputation: 30
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
 
Old 05-12-2005, 07:41 AM   #2
trevelluk
Member
 
Registered: Nov 2003
Location: Bristol, UK
Distribution: Debian Lenny, Gentoo (at work)
Posts: 388

Rep: Reputation: 32
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
 
Old 05-12-2005, 07:45 AM   #3
jeffreybluml
Member
 
Registered: Mar 2004
Location: Minnesota
Distribution: Fedora Core 1, Mandrake 10
Posts: 405

Original Poster
Rep: Reputation: 30
Excellent!

Thank you!!

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


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell variable in Linux is reset after while loop CBenner Programming 7 05-19-2006 09:46 AM
Automaticly incrementing Version Number BoldKiller Programming 7 03-26-2005 12:08 PM
getting a variable out of a WHILE loop. fhinkle Programming 8 02-22-2005 04:43 AM
Incrementing volume through amixer mpn Linux - General 1 10-30-2004 08:42 PM
RX bytes: xxxx stop incrementing gyu Linux - Networking 1 03-10-2003 09:42 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration