LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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 04-25-2010, 01:31 PM   #1
sinderone
LQ Newbie
 
Registered: Apr 2010
Posts: 6

Rep: Reputation: 0
Trying to read a file with a while loop.


I am a student at ITT and am just lurning about scripting and need to read a file and output the file to the screen. We need to do this with a while loop. Can someone help me with the coding for it?
 
Old 04-25-2010, 01:34 PM   #2
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,189

Rep: Reputation: 105Reputation: 105
Policy on these forums is not to do homework for people.

If you take a stab at it and have difficulties, you can ask some specific questions about what you are doing. But, you shouldn't expect to just describe your homework problem and have someone hand you a script.
 
Old 04-25-2010, 01:48 PM   #3
sinderone
LQ Newbie
 
Registered: Apr 2010
Posts: 6

Original Poster
Rep: Reputation: 0
I am not trying to get them to do my homework I relly just need help with how to get a while loop to read a file. If I can get some help with that I can do the rest of it np. I am just getting stack on how to read a file in to the loop.
 
Old 04-25-2010, 02:47 PM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729
Per the LQ Rules, please do not post homework assignments verbatim. We're happy to assist if you have specific questions or have hit a stumbling point, however. Let us know what you've already tried and what references you have used (including class notes, books, and Google searches) and we'll do our best to help. Also, keep in mind that your instructor might also be an LQ member.

Above is our canned response---the key in your case is to tell us which books and reference material you have used, and to show us what you have tried.

For example, do you know how to make a perpetual loop that simply prints the word "hello"?

Next, are you familiar with the "read" command?----and have you studied redirection?
 
Old 04-25-2010, 03:53 PM   #5
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 3,919

Rep: Reputation: 779Reputation: 779Reputation: 779Reputation: 779Reputation: 779Reputation: 779Reputation: 779
I think you'll find that most people here feel that if it quacks like a homework question and it waddles like a homework question, its a homework question, unless you get a very convincing explanation.

@pixellany
Quote:
the key in your case is to tell us which books and reference material you have used, and to show us what you have tried.
...and, if i can make a suggestion, a bit more of a hint about any restrictions on programming or scripting language is to be used, could be helpful.

Quote:
Originally Posted by sinderone View Post
We need to do this with a while loop. Can someone help me with the coding for it?
Whether this is an answer, or not, a resource that you might like is here.
 
Old 04-26-2010, 03:37 AM   #6
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,698

Rep: Reputation: 1988Reputation: 1988Reputation: 1988Reputation: 1988Reputation: 1988Reputation: 1988Reputation: 1988Reputation: 1988Reputation: 1988Reputation: 1988Reputation: 1988
My first question is, what did your last google slave die of???

I mean seriously, assuming we are talking bash scripting, simply using the words bash, while and loop returns 1.5 million results.
One would think one of those might help.
 
1 members found this post helpful.
  


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
BASH: Read entire file line in for loop clinton Programming 16 04-18-2013 01:06 PM
how to loop over text file lines within bash script for loop? johnpaulodonnell Linux - Newbie 8 04-05-2011 10:18 AM
How can I read a file line by line and add it to a loop in another file? astroumut Linux - Newbie 7 08-24-2009 05:37 AM
Reg Makefile : Read file : for loop mogra Linux - Newbie 2 03-16-2008 01:57 PM
while READ loop problem caps_phisto Linux - General 3 02-05-2007 10:58 AM


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