1

This post 'Output file contents while they change' is similar but the answer doesn't work for my case. Tail -f doesn't seem to refresh the output when the file's size doesn't change or when there are no new rows added.

The file I'm trying to monitor/watch in SSH holds the value of a Volt Meter reading and it changes frequently (about every two or three seconds) but tail -f doesn't output the changes. Is there any other command similar to tail that can be used or does this require a custom binary?

HK1
  • 113
  • 4

1 Answers1

3

If the filesize doesn't change then the file isn't being appended to, it's being overwritten.

Depending on how the file is being rewritten, tail -F (capital F) may detect the change and rewrite it.

Otherwise if the file is small (e.g. just one line) then something like

while [ 1 ]
do
  cat file
  sleep 2
done

Will redisplay the file every 2 seconds. Fortunately there's a command that makes this easier

$ watch cat file
Stephen Harris
  • 42,369
  • 5
  • 94
  • 123