LinuxQuestions.org
Review your favorite Linux distribution.
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, 11: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, 11:53 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 2,171

Rep: Reputation: 752Reputation: 752Reputation: 752Reputation: 752Reputation: 752Reputation: 752Reputation: 752
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, 11: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, 12:01 PM   #4
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 2,171

Rep: Reputation: 752Reputation: 752Reputation: 752Reputation: 752Reputation: 752Reputation: 752Reputation: 752
You were given part of a script to debug, not a command line.
 
1 members found this post helpful.
Old 12-16-2013, 12:05 PM   #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, 12:48 PM   #6
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,189
Blog Entries: 10

Rep: Reputation: 1982Reputation: 1982Reputation: 1982Reputation: 1982Reputation: 1982Reputation: 1982Reputation: 1982Reputation: 1982Reputation: 1982Reputation: 1982Reputation: 1982
Have a look at
http://mywiki.wooledge.org/BashGuide...ndConditionals
 
1 members found this post helpful.
Old 12-16-2013, 01: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 01:07 PM.
 
1 members found this post helpful.
Old 12-16-2013, 01: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


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


All times are GMT -5. The time now is 03:52 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration