I have a stream of info from a serial input (GPS Antennae) and wish to output that info into a text file on every input (every second in this case) but instead of appending it to the end of the file as > would do after the initial overwrite I would like it to overwrite it every second so only the latest info is displayed.
I have tried \r which achieves the effect in bash but not the output file.
cat /dev/ttyACM0 | grep --line-buffered -E "GNGGA" | awk 'BEGIN {FS=","};{printf "%s%s\t\t%s%s\t\t%s%s\t%s%s","Time= ",$2,"Lat= ",$3,"Lon= " ,$5,"Alt= " ,$10; fflush(stdout) }' > somefiles.txt
This includes the initial input, a grep to focus on one line and awk to get the specific parts of the info I need, they don't affect the overwrite issue as far as I know.
Time= 155325.00 Lat= 7428.77433 Lon= 82845.15963 Alt= 21.5
This is the output that starts by overwriting the somefiles.txt but then appends until you stop and run the command again.
So is there a way to make only the latest input appear as one line in the text file?
Thanks