I have a shell script that which I am facing an issue with the data output is string I think it is empty string and what output should be a float I am not shell script coder and never did but I am looking for someone to fix it. the script is used to take values from bandwidth table created using vnstat package.
tempout1=$(vnstat -h| tail -n 2| awk -F '{ print $11}'| tail -n 1| awk -F, '{ print $1}')
tempout2=$(vnstat -h| tail -n 2| awk -F '{ print $11}'| tail -n 1| awk -F, '{ print $2}')
o=$tempout1$tempout2
bandwidth_out_unit=$(vnstat -h| tail -n 9| awk -F) '{ print $6}'| head -n 1|awk -F( '{ print $2}')
#echo $bandwidth_out_unit
case "$bandwidth_out_unit" in
KiB) bandwidth_out_number_Byte=$(echo "$o*1024"| bc)
;;
MiB) bandwidth_out_number_Byte=$(echo "$o*1024*1024"|bc)
;;
GiB) bandwidth_out_number_Byte=$(echo "$o*1024*1024*1024"|bc)
;;
TiB) bandwidth_out_number_Byte=$(echo "$o*1024*1024*1024*1024"|bc)
;;
esac
#echo $bandwidth_out_number_Byte
echo $bandwidth_out_number_Byte
my expectation is to output the total_outbound_for_current_hour but instead it is output nothing can you fix that btw I don’t get it. How I know I run ./fileexample.sh command