Created
March 27, 2014 19:53
-
-
Save brycebaril/9816749 to your computer and use it in GitHub Desktop.
Split a file into a file per line of the input file.
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
var fs = require("fs") | |
var split = require("binary-split") | |
var terminus = require("terminus") | |
var path = require("path") | |
var input = process.argv[2] | |
var dir = path.dirname(input) | |
var basename = path.basename(input) | |
var count = 0 | |
fs.createReadStream(input) | |
.pipe(split()) | |
.pipe(terminus(function (chunk, encoding, callback) { | |
fs.appendFile(path.join(dir, count + "_" + basename), chunk) | |
count++ | |
callback() | |
})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment