8

I use -x for debug info while executing the shell script.

How can I redirect debug info only to a file?

Example script:

#!/bin/bash
echo OK
echo NO

i will get the below result when i run in debug mode

+ echo OK
OK
+ echo NO
NO

I would like to redirect only the debug info to a file.

+ echo OK
+ echo NO

And runtime output should print on the screen.

OK
NO
Siva
  • 9,077

1 Answers1

9

Try this,

 sh -x script.sh 2> out.log
Siva
  • 9,077