LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 12-09-2010, 01:28 PM   #1
tayyyar
LQ Newbie
 
Registered: Dec 2010
Posts: 2

Rep: Reputation: 0
Terminal problem


hi ı'm using fedora 14
and ı have a problem

ı want to try some codes to run in terminal but ı got error ı didn't figure out what is the problem and how can ı fix it please help me!! thank you

while[$i -le 10]
do
echo "$n * $i ='expr $i \* $n'"i='expr $i + 1'
done
----------
ı'm getiing line 1: [: missing ']'
 
Old 12-09-2010, 01:37 PM   #2
xeleema
Member
 
Registered: Aug 2005
Location: D.i.t.h.o, Texas
Distribution: Slackware 13.x, rhel3/5, Solaris 8-10(sparc), HP-UX 11.x (pa-risc)
Posts: 988
Blog Entries: 4

Rep: Reputation: 254Reputation: 254Reputation: 254
Greetings!

Assuming you're using the bash shell, try this;

while true
do
if [ $i -le 10 ]; then
echo "$n * $i = 'expr $i \* $n'"
i='expr $i + 1'
fi
done


If that doesn't work, I would re-read that chapter in your classbook.
 
Old 12-09-2010, 01:48 PM   #3
tayyyar
LQ Newbie
 
Registered: Dec 2010
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by xeleema View Post
Greetings!

Assuming you're using the bash shell, try this;

while true
do
if [ $i -le 10 ]; then
echo "$n * $i = 'expr $i \* $n'"
i='expr $i + 1'
fi
done


If that doesn't work, I would re-read that chapter in your classbook.
thanks for your respond but that you wrote get inside the infinite loop wants

-le: unary operator expected

ı should check it my slayts one more time
 
Old 12-09-2010, 01:55 PM   #4
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 555Reputation: 555Reputation: 555Reputation: 555Reputation: 555Reputation: 555
Quote:
-le: unary operator expected
Hint: Between the lines, that error is telling you that the variable you are comparing in your test, is not an integer. So, investigate how $i is getting set, i.e. is it getting set to a string value by accident or by logic error (or perhaps it is empty when the loop begins?)?
 
Old 12-09-2010, 02:01 PM   #5
xeleema
Member
 
Registered: Aug 2005
Location: D.i.t.h.o, Texas
Distribution: Slackware 13.x, rhel3/5, Solaris 8-10(sparc), HP-UX 11.x (pa-risc)
Posts: 988
Blog Entries: 4

Rep: Reputation: 254Reputation: 254Reputation: 254
@tayyyar
I left out a "then if i = 10...break" intentionally. We get quite a few "homework questions" here, and I wasn't sure if that's what your post was.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
problem with terminal sattulinux Linux - Newbie 31 09-17-2010 11:26 PM
terminal problem ambavaram Linux - Software 3 07-09-2008 03:45 AM
terminal problem jaspreet85 Linux - General 3 07-20-2005 10:15 AM
terminal problem HmmLinux Linux - General 3 11-11-2004 12:34 PM
qt: terminal problem powadha Slackware 1 12-23-2003 05:17 PM

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

All times are GMT -5. The time now is 08:39 AM.

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