Created
October 17, 2012 20:51
-
-
Save mcculloughsean/3908099 to your computer and use it in GitHub Desktop.
Pipe stdin to a 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
#!/usr/bin/env node | |
var fs = require('fs'); | |
var outputFile, outputStream; | |
if (process.argv[1] == __filename) | |
outputFile = process.argv[2]; | |
if (!outputFile) { | |
throw "Must specify a filename"; | |
} | |
outputStream = fs.createWriteStream(outputFile); | |
process.stdin.pipe(outputStream); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment