ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I have a text file that needs to be read, printed, and then saved as a variable. I know that to read and print a file I would use:
But after it is read and printed, how would I save it as a variable. To give everyone a bit more insight on what I am trying to do. I have a text file that is overwritten every second...it looks like this
These four values are overwrote by new values every second. I need to find a function to save this as a variable and read the new text file evey second. How would I do this?
Could you explain your code better...I am new to shell coding and do not understand what you are tryinging to do. It looks like your setting up an array, but this program will run all day everyday and a new textfile will be generated ever second of the day, therefore; I would not want an array just some type of loop that will constantly read and print out the text file and only stop on a command.
Would I get the following functionality:
1) Whatever is in filename will be read and set to the variable foo
2) I print foo to the screen
3) Wait and then repeat.........read....set equal to foo.....print......read....set equal to foo.....print..etc
If so what will the done do and how would I ever get out of this loop if I needed to....or is there a better way to structure my loop?
that loop is infinite. You can always hit control-C on your terminal to kill it. If you want some other terminating condition, tell us what it should be : )
The "done" just tells the shell that's where the bottom of the loop is; stuff below done won't be included in the loop. (The shell doesn't know what you mean by indenting the body of the loop; you just do that so it's more readable to a human)