Last active
December 1, 2020 19:43
-
-
Save karan9/c8d5bf7f6f50b352066bc9151e7e0b5d to your computer and use it in GitHub Desktop.
Simple MongoDB Log Fixer For People who use windowwwwzzzz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const rl = require("readline"); | |
const FILEPATH = "/Users/Karan.Srivastava/Desktop/Manish Sahni/s1.log"; | |
const OUTPUTFILE = "s1k.log"; | |
const lineReader = rl.createInterface({ | |
input: require("fs").createReadStream(require("path").normalize(FILEPATH)) | |
}) | |
let prevLine = ""; | |
lineReader.on("line", (line) => { | |
if (line.startsWith("2020") && prevLine) { | |
require("fs").appendFileSync(OUTPUTFILE, prevLine + require("os").EOL, { encoding: "utf-8" }) | |
prevLine = ""; | |
prevLine = line; | |
} else { | |
prevLine += line | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment