Comment by frou_dh
10 years ago
It bugged me that Sublime Text used to do these so-called atomic saves by default since it screwed with basic unix expectations like fstat and fseek meaningfully working (like a tail -f implementation could boil down to[0]). A concurrently running process using those calls would be off in lala-land as soon as the text file was modified and saved: it would never pick up any modifications, because it and the editor weren't even dealing with the same file any more.
[0] Here's follow(1) in my homemade PL:
#!/usr/bin/env imp
(when (not-eq? (length script-args) 1)
(write (sprintln "usage: " script-name " <path>") stderr)
(exit 1))
(let path (car script-args)
f (open path)
((proc (stat-then)
(let stat-now (stat f)
(seq (when (and? stat-then
(lt? (find 'size stat-now)
(find 'size stat-then)))
# The file was truncated. Read from the start.
(seek s-set 0 f))
(let bytes (read default-chunk f)
(seq (when bytes (print bytes))
(sleep 1000)
(recur stat-now))))))
FALSE))
GNU tail lets you say "--follow=descriptor" to follow the content of the file no matter how it gets renamed, or "--follow=name" to re-open the same filename when a different file gets renamed onto it.
That's the difference between 'tail -f' and 'tail -F' and is implemented in every tail I know of.
indeed. `tail -qF` has been muscle memory for me for as long as I can remember.
if you have long lived sessions tail'ing logs that get rotated (or truncated), forgetting -F is a good way to eventually end up confused, ctrl-c'ing, and finally cursing.