Skip to content

Instantly share code, notes, and snippets.

@MichelBartz
Forked from bratish/tail-f.js
Created October 28, 2010 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save MichelBartz/652308 to your computer and use it in GitHub Desktop.
Save MichelBartz/652308 to your computer and use it in GitHub Desktop.
/**
* A `tail -f` implementation in Node.js.
*
* Original author : Bratish Goswami <bratishgoswami AT gmail DOT com>
* Modified by : Michel Bartz <michel.bartz AT manwin DOT com>
*
*/
var sys = require("sys"),
fs = require('fs'),
f = "/path/to/file";
fs.watchFile(f, function(curr, prev) {
fs.createReadStream(f, { start: prev.size, end: curr.size}).addListener("data", function(lines) {
sys.log(lines);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment