This is a question which isn’t linked to any practical situation I’m in, but it always bugged me.
What could go wrong if I have one script reading and appending lines in one text file and another script reading from the same file?
I know that when a script opens a text file it’s working with the version of that file from the moment it has been opened, not considering following edits. I want both script to be working with the latest possible version (I recon it won’t be real-time) of the text file.
I guess one way of putting the question is: which is the best way to handle said scripts? When should I close and open the file in the first one?
This is wrong statement. For example try following command in Unix:
And then try to add lines to that file.
tailcommand will follow your additions. (assuming you doflushperiodically when writing).