I have a script like the one below:
#!/bin/bash
#func.sh
func(){
badcommand1
echo "OK"
badcomand2
}
func 2>&1 > err.log
#The top line is in the file
My goal is to redirect all outputs and errors to file err.log but unfortunately, it only prints "OK" to the log file.
Bash version is: GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)
Can anybody help?