LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Question please help, (https://www.linuxquestions.org/questions/linux-newbie-8/question-please-help-4175488146/)

dyang 12-16-2013 10:35 AM

Question please help,
 
I tried everything trying to run this question on my linux.
please let me know what I need to do?


question:
"What is wrong with the following lines of code?
While [ "$value" = "100" ; do
Echo "That’s a large number."
fi"

what I did:

what I did:
while ["value" = "100"] ; do

My instructor reply:
Answer: 1) there should be a closing bracket after “100”, 2) Echo should not have an initial capital letter, 3) there should be a semicolon on the second line to separate number.” and read value, and the third line should have done instead of fi.

explain to me what I'm missing... please and thank you

TenTenths 12-16-2013 10:53 AM

By taking the $ away from $value you've changed it from a variable to a fixed string of the word value

And as for the rest, your instructor is correct, what parts don't you understand?

dyang 12-16-2013 10:58 AM

I didn't understand when my instructor says

3) there should be a semicolon on the second line to separate number.” and read value, and the third line should have done instead of fi.

I run the command line but it gave me this:


user@user-HP-Compaq-nc6400-EH521AV:/home$ while ["value" = "100"] ; do
>

explain why my instructor says:
"there should be a semicolon on the second line to separate number.” and read value, and the third line should have done instead of fi."


which I don't know where and when I should input fi in the command at all

TenTenths 12-16-2013 11:01 AM

You were given part of a script to debug, not a command line.

dyang 12-16-2013 11:05 AM

So all i need to debug is
while ["value" = "100" ; do
> echo "that's a large number"

????

Habitual 12-16-2013 11:48 AM

Have a look at
http://mywiki.wooledge.org/BashGuide...ndConditionals

yooden 12-16-2013 12:05 PM

Quote:

Originally Posted by dyang (Post 5081657)
So all i need to debug is
while ["value" = "100" ; do
> echo "that's a large number"

????

I don't understand your instructor's 3), I don't see a reason to add a semicolon.

However, you could put everything in one line, and would need semicolons then (untested):
Code:

while [ "$value" = "100" ]; do; echo "That's a large number."; done
Note: Please use a more useful subject next time.

dyang 12-16-2013 12:22 PM

Awesome! Thanks guys! Yooden U the best...! I didn't know I was only missing the "done" part in the end. hahaa


All times are GMT -5. The time now is 07:02 PM.