Redirect error message to logfile
please help me in redirecting the error messages of this code to a log file.
for f in *.log; do
awk 'NF && NR>1 && $0!~/total:/
{
things_cost=$2*$3;
overalltotal=(overalltotal!="")? overalltotal"+"things_cost : things_cost;
if(things_cost!=$4)
{
things_er[$1]=things_cost" instead of "$4
}
err_t+=$4; t+=things_cost;
}
$0~/total/ && err_t
{
print "Error in calculations:";
for(i in things_er)
{
print "Things total for "i" is wrong: it should be "things_er[i]
}
print "Overalltotal is wrong: It should be "t; next
}1' "$f" 2> error.log
done
|