Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

bash commands in node

const { exec } = require('child_process');
exec('ls | grep js', (err, stdout, stderr) => {  
  if (err) {    
    //some err occurred    
    console.error(err)  
  } else {   
    // the *entire* stdout and stderr (buffered)   
    console.log(`stdout: ${stdout}`);   
    console.log(`stderr: ${stderr}`);  
  }
});
Source by medium.com #
 
PREVIOUS NEXT
Tagged: #bash #commands #node
ADD COMMENT
Topic
Name
1+8 =