Skip to main content
2 of 3
edited body
e15purple
  • 33
  • 1
  • 1
  • 4

Bash Script exec file descriptor returning "not found"

I want to set all debugging output to a log file. So I checked https://askubuntu.com/questions/811439/bash-set-x-logs-to-file and followed the instructions.

test-script:

#!/bin/bash
exec 5 >/var/log/test.log
export BASH_XTRACEFD=5
main(){
set -x
echo hello
set +x
}
main

run:

./test-script

returns:

exec: 5: not found

The manual shows you can do this as well, so why is the above not working?

e15purple
  • 33
  • 1
  • 1
  • 4