0

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

2
  • Double up the back slash characters. Commented May 2, 2014 at 5:15
  • means....can u please chnage my code..i didnt get u Commented May 2, 2014 at 5:19

1 Answer 1

2

Double up the back slashs:

command +='find -type f -printf %T+\\t%p\\n | sort -n'
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.