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.
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)