Just like we redirect output from a for loop block to a file
for ()
do
//do something
//print logs
done >> output file
Similarly in shell script, is there a way to redirect output from a function block to a file, something like this?
function initialize {
//do something
//print something
} >> output file
//call initialize
If not, is there some other way I can achieve that? Please note my function has lot of messages to be printed in a log. Redirecting output to a file at every line would result in a lot of I/O utilization.