I'm trying to print output/error to console and log file using below code.
fun1(){
echo "inside fun1"
fun2
var=5
}
fun2(){
echo "inside fun2"
}
fun1 2>&1 | tee -a testlog.txt
echo $var # printing null value
Any way to print value of var as 5 after fun1 execution?? I need output in both console and log file. Also fun1 should be executed only once.
please help.