Search code examples
bashbash4

Use set -x and export to a file


Is there any way to export all the output of set -x to a file? my exercise is to use set -x do some functions like mkdir and touch and export all the output to a file.

Thanks


Solution

  • $ (set -x; echo hello) &> foo.txt
    
    $ cat foo.txt
    + echo hello
    hello
    

    Example