Sample Header Ad - 728x90

How to [constantly] read the last line of a file?

0 votes
3 answers
11298 views
I have client filtering out data from an live MQTT stream which writes the data into a myfile.csv file, here are the last four lines:
1426134425,m,NWRL,MSV,001,d,SVlts,139,1840343,26089,28529,15987
1426134444,m,NWRL,MSV,001,d,status,139,1859000,23911,-33.836465,151.051189
1426134834,m,gf,TMX6BP,075,d,SVlts,216,1243746,27209,27409,17106
1426134845,m,gf,TMX6BP,075,d,status,216,1254000,179583,-33.836465,151.051189
This file constantly gets updated. So the last line of the csv file would constantly be changing however it would still be in the same format. __Q:__ How can I read the last line where the 7th value is 'status' not 'SVlts' of the myfile.csv file with bash? Once read how can I assign the 4th, 5th and 10th value to a 3 different variables? I will be pushing these values out to update a MySQL table. So the output can be something as follows:
variable_1=TMX6BP
variable_2=075
variable_3=179583
As mentioned these three variables will be pushed/sent out to update a MySQL table (which needs these three variables in order to update itself) until the next line is printed in to the myfile.csv. And this will happen over and over again.
Asked by 3kstc (4996 rep)
Mar 12, 2015, 05:10 AM
Last activity: Mar 13, 2015, 12:13 PM