Title: node.js exec command quote
Tags: node.js;exec
Question: i have this command on linux to get my ip adress :
```connmanctl services ethernet_00142d000000_cable | sed -n -e '/IPv4 =/s/.*Address=\([^,]*\).*/\1/p'```
i want to use it in a exec function using Child Process like this :
```const exec = require('child_process').exec;
exec(' connmanctl services ethernet_00142d000000_cable | sed -n -e '/IPv4 =/s/.*Address=\([^,]*\).*/\1/p' ', (error, stdout, stderr) =&gt; {
  if (error) {
    console.error(`exec error: ${error}`);
    return;
  }
  console.log(`stdout: ${stdout}`);
  console.log(`stderr: ${stderr}`);
});
```
I got nothing and i dont know how i can exec a command with quote.
thanks for your help



Here is another answer: One of the easiest options is to wrap the command in double quotes, but this may cause ESlint error, because of mixing double and single quotes.
```const exec = require('child_process').exec;
exec(&quot; connmanctl services ethernet_00142d000000_cable | sed -n -e '/IPv4 =/s/.*Address=\([^,]*\).*/\1/p' &quot;, (error, stdout, stderr) =&gt; {
  if (error) {
    console.error(`exec error: ${error}`);
    return;
  }
  console.log(`stdout: ${stdout}`);
  console.log(`stderr: ${stderr}`);
});
```
Another option is to use Template literals:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
``` const exec = require('child_process').exec;
    exec(` connmanctl services ethernet_00142d000000_cable | sed -n -e '/IPv4 =/s/.*Address=\([^,]*\).*/\1/p' `, (error, stdout, stderr) =&gt; {
      if (error) {
        console.error(`exec error: ${error}`);
        return;
      }
      console.log(`stdout: ${stdout}`);
      console.log(`stderr: ${stderr}`);
    });
```


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2020:00:08/10/20', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<node.js><exec>', 'Title': 'node.js exec command quote', 'ViewCount': 214, 'id': 63344656, 'user_AboutMe': None, 'user_AccountId': 19149059.0, 'user_DisplayName': 'Tupperware', 'user_Reputation': 3.0, 'user_Views': 5.0, 'user_id': 13987369.0}}