LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-16-2013, 10:35 AM   #1
dyang
LQ Newbie
 
Registered: Dec 2013
Posts: 11

Rep: Reputation: Disabled
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
 
Old 12-16-2013, 10:53 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
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?
 
1 members found this post helpful.
Old 12-16-2013, 10:58 AM   #3
dyang
LQ Newbie
 
Registered: Dec 2013
Posts: 11

Original Poster
Rep: Reputation: Disabled
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
 
Old 12-16-2013, 11:01 AM   #4
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
You were given part of a script to debug, not a command line.
 
1 members found this post helpful.
Old 12-16-2013, 11:05 AM   #5
dyang
LQ Newbie
 
Registered: Dec 2013
Posts: 11

Original Poster
Rep: Reputation: Disabled
So all i need to debug is
while ["value" = "100" ; do
> echo "that's a large number"

????
 
Old 12-16-2013, 11:48 AM   #6
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Have a look at
http://mywiki.wooledge.org/BashGuide...ndConditionals
 
1 members found this post helpful.
Old 12-16-2013, 12:05 PM   #7
yooden
Member
 
Registered: Dec 2013
Distribution: Debian Wheezy/Jessie # XFCE
Posts: 53

Rep: Reputation: Disabled
Quote:
Originally Posted by dyang View Post
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.

Last edited by yooden; 12-16-2013 at 12:07 PM.
 
1 members found this post helpful.
Old 12-16-2013, 12:22 PM   #8
dyang
LQ Newbie
 
Registered: Dec 2013
Posts: 11

Original Poster
Rep: Reputation: Disabled
Awesome! Thanks guys! Yooden U the best...! I didn't know I was only missing the "done" part in the end. hahaa
 
  


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
[SOLVED] GPL question (Version 2, June 1991) - physical media availability question LicenseQuestions Linux - Newbie 1 12-01-2012 06:34 PM
basic html question - download link to files on my webpage question Davno Linux - Server 5 12-25-2009 07:24 AM
linux distro question & mysql install question natalie.aloi Linux - Newbie 5 07-19-2009 08:28 PM
Question, Apples Contribution to Open Source + MacOs file structure question Higgy3k Other *NIX 5 07-25-2005 04:23 AM
login prompt question & kde scheme question JustinCoyan Slackware 2 06-09-2004 02:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:30 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