LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Trying to read a file with a while loop. (https://www.linuxquestions.org/questions/programming-9/trying-to-read-a-file-with-a-while-loop-804112/)

sinderone 04-25-2010 12:31 PM

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?

choogendyk 04-25-2010 12:34 PM

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.

sinderone 04-25-2010 12:48 PM

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.

pixellany 04-25-2010 01:47 PM

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?

salasi 04-25-2010 02:53 PM

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 (Post 3947257)
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.

grail 04-26-2010 02:37 AM

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.


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