title: Node.js function output to variable
body: <p>i have a grep function that i am using to seperate some data out.</p>
  
  <p>I ran into an issue, instead of outputting the data to the console, i need it to store it to a variable.  </p>
  
  <p>for example, here is my actual function.</p>
  
  <pre><code>function funGrep(cmd,callback,search,args){
      exec(cmd,function(err,stdout){
          if(!stdout)
              return;
          var lines = stdout.toString().split(EOL);
          var re = new RegExp(search,args);
          for(var line in lines){
              var results = lines[line].match(re);
              if(results){
                  for(var i = 0; i &lt; results.length; i++){
                      callback(results[i]);
                  }
              }
          }
      });
  }
  </code></pre>
  
  <p>and here is my actual calling of the function into play. </p>
  
  <pre><code>funGrep("ping -n 3 google.com",console.log,"time=[0-9\.]+ ?ms");
  </code></pre>
  
  <p>instead of logging the output to the console, how can i just assign it to a variable like output.</p>
  
  <p>thank you!</p>