Created
March 3, 2016 01:09
Revisions
-
jamesmontalvo3 created this gist
Mar 3, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ fs = require('fs'); path = require('path'); var log = path.join( path.dirname( fs.realpathSync(__filename) ), 'meza-dev.log' ); fs.readFile( log, 'utf8', function(err,data){ if (err) { return console.log(err); } var lines = data.split("\n"); var count = lines.length; console.log( count + " lines..." ); var i = 0; var newFileText = ""; while( lines[i] ) { newFileText += lines[i] + "\n"; if ( i % 20000 === 0 ) { fs.writeFile( "log" + i + ".log", newFileText.substr(), 'utf8', function(err){ if(err) { console.log(err); } }); newFileText = ""; } i++; } });