I tried to Realize the function shown as the below FAKE code: to compute the net down rate and update the net log. May somebody show me the right code? Thanks.
#!/bin/bash
#check_net.sh
net_link_error_total=33
net_link_ok_total=55
save_link_rate()
{
sed -i '1 cnet_link_error_total=$net_link_error_total' yy.log
sed -i '2 cnet_link_ok_total=$net_link_ok_total' yy.log
net_link_ok_rate=net_link_ok_total/(net_link_ok_total+net_link_error_total) * 100%
sed -e "3c net_link_ok_rate= /$net_link_ok_rate" yy.log
}
save_link_rate
After I executed sed -i '2 cnet_link_ok_total=$net_link_ok_total' yy.log
The yy.log is
net_link_error_total=$net_link_error_totalBUT I want it to be
net_link_error_total=33.