Tagged: cli

0

How to run cli/unix commands from nodejs scripts?

There are two ways to do this: child_process.exec(command[, options][, call­back]) // ls.js const { exec } = require(‘child_process’); exec(‘ls –lh /usr’, (error, std­out, stderr) => { if (error) { console.error(‘exec error: ${error}‘); return; } console.log(‘stdout:…

0

Autocomplete cli from history

Use the fol­low­ing steps to do the reverse search in your bash his­tory. $ Ctrl + R $(reverse-i-search)‘’: [start typ­ing com­mand…] [Tab/Enter] — Tab will com­plete the com­mand and brings back the CLI. -…

0

$? variable in linux

$? Sta­tus of the pre­vi­ous process / com­mand which ran on the shell $ pwd $ echo $? // returns 0 which means the pre­vi­ous com­mand ran sucess­fully $ blah­Com­mand $echo $? // returns 1…