Reputation: 1457
Am trying to execute following shell command in nodejs script.it is working fine in terminal
find -type f -printf %T+\t%p\n | sort -n
node script
var command = ' cd ~/home'
command +=' find -type f -printf %T+\t%p\n | sort -n'
exec(command, function (error, stdout, stderr) {
});
while executing the above code am getting
exec error: Error: Command failed: /bin/sh: 2: Syntax error: "|" unexpected
How can i solve this eroor
Upvotes: 0
Views: 1080
Reputation: 4604
Double up the back slashs:
command +='find -type f -printf %T+\\t%p\\n | sort -n'
Upvotes: 2