I have a netflow output in which certain lines are showing 'M' after bytes:
2014-05-10 14:26:49.231 10.335 UDP 114.31.254.227:24874 -> 56.213.85.253:13617 9 1139 1
2014-05-10 14:26:59.494 0.222 UDP 114.31.254.193:17769 -> 165.199.57.179:40012 3 172 1
2014-05-10 14:26:56.015 3.348 TCP 96.196.161.39:80 -> 114.31.255.131:61066 5428 7.8 M 1
2014-05-10 14:26:59.705 0.246 UDP 165.199.57.144:40007 -> 114.31.254.193:17769 3 140 1
As can be seen there is an instance of '7.8 M' which I would like to show as its true byte value, not megabytes.
I want to replace all megabyte vales with their byte vales (multiplying by 1,048,576).
Code along the lines of: match '[number string] M ' multiply number by 1048576 and replace
The column is 9-10 on lines with M
Perhaps using awk?:
cat whitespacetrim.out | grep ' M ' | cut -f 9,10 -d ' '| cut -f 1 -d ' ' | awk '{val=$1*1024*1024} END {print val}'|