Skip to content

Instantly share code, notes, and snippets.

@NaClYen
Created November 19, 2021 03:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NaClYen/07ee916d1b01f79d8bce043326cbe5f8 to your computer and use it in GitHub Desktop.
Save NaClYen/07ee916d1b01f79d8bce043326cbe5f8 to your computer and use it in GitHub Desktop.
nodejs read file line by line with built-in readline and fs
const readline = require("readline");
const fs = require("fs");
const input = fs.createReadStream("my.log", {
encoding: "utf-8",
});
const rl = readline.createInterface(input);
rl.on("line", (line) => {
console.log(line);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment