Home>

I am measuring the latitude and longitude of GPS in a log file and outputting it to the log file every 3 seconds. How can I get only the end of the log file?

  • Answer # 1

    Do you want only the last log?
    What if you prepare a file for overwriting separately from the log file output (append)?
    The file is always overwritten at the timing of log output.

    I am sorry if the intention is different.

  • Answer # 2

    What about thetailcommand?

  • Answer # 3

    I don't really answer questions that don't have a code at all ...
    python doesn't work unless the indentation is correct

    tail-like implementation (3 lines)

    import sys
    import collections
    deque = collections.deque (maxlen = 3)
    for line in sys.stdin.readlines ():
        deque.append (line)
    for line in deque:
        print (line, end = "")