Skip to content

Instantly share code, notes, and snippets.

@temsa
Created February 14, 2011 10:14
Show Gist options
  • Save temsa/825687 to your computer and use it in GitHub Desktop.
Save temsa/825687 to your computer and use it in GitHub Desktop.
Cat a file with node in one line
#!/usr/local/bin/node
require(‘fs’).readFile(process.argv[2], function(err,buf){ process.stdout.write(buf); });
#!/usr/local/bin/node
var args = process.argv.splice(2,process.argv.length-1);
args.forEach(function (file){
if(args.length >1)
console.log(‘========> %s <=========’,file);
require(‘fs’).readFile(file, function(err,buf){
process.stdout.write(buf);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment