1 var spawn = require('child_process').spawn;
3 var find = spawn('find',[process.argv[2]||'./']);
5 var fs = require('fs');
7 var buf = '',count = 0;
9 handleBuf = function(data){
13 if(buf.length >= 1024) {
14 var lines = buf.split("\n");
15 buf = lines.pop();//last line my not be complete
16 count += lines.length;
17 process.stdout.write(lines.join("\n")+"\n");
21 find.stdout.on('data',function(data){
22 //buf += data.toString();
24 //process.stdout.write(data.toString());
27 find.on('end',function(){
29 console.log('found '+count+' files');