Log file has certain string happening several time. I need to capture next line for all occurrences of this previous string with node.js. For example content of the file:
Indulgence announcing uncommonly met she continuing two unpleasing terminated. Now busy say down the shed eyes roof paid her
Compile Error
./aaarty/bbb/cfvcc/dddhjklpi
Course suffer to do he sussex it window advice. Yet matter enable misery end extent common men should. Her indulgence but assistance favourable cultivated everything collecting
Compile Error
./asshtyd/wrfber/ghn/fffh/gh/ikjmlk
Extended kindness trifling remember he confined outlived if. Assistance sentiments yet unpleasing say
Compile Error
./cc/wwwasftbb/kkk/tgfh/pioqascfg/qqq
Open they an busy they my such high strong text
Using node.js I need to capture each line that goes after the line with the string "Compile Error"
I got it:
var fs = require('fs');
var array =
fs.readFileSync('mylogfile.txt').toString().split("\n");
for(let i in array) {
if (array[i] == "Compilation Error")
{
let k = parseInt(i)+parseInt(1)
console.log(array[k])
}
}