I have a file which contains values in KB
and MB
. How can I, in a for
-loop calculate the sum of the values in MB for both MB
and KB
?
For MB, This gives me the values and then I need to sum those:
cat usage_1.12.2015_31.12.2015.xls.csv | grep MB | awk -F '"' '{print $4}' | awk '{print $1}'
Output:
17
16
13
17
14
3
3
12
10
8
6
10
KB
student@student-vm:~/Downloads$ cat usage1.12.2015_31.12.2015.xls.csv | grep KB
"2015/12/28 14:15:46","109 KB",,0
"2015/12/28 14:13:47","331 KB",,0
"2015/12/21 11:01:34","762 KB",,0
"2015/12/20 19:51:40","253 KB",,0
"2015/12/07 07:18:50","81 KB",,0
"2015/12/03 14:56:06","407 KB",,0
MB
student@student-vm:~/Downloads$ cat usage1.12.2015_31.12.2015.xls.csv | grep MB
"2015/12/06 15:54:47","10 MB",,0
"2015/12/06 09:43:02","4 MB",,0
"2015/12/05 21:39:04","21 MB",,0
"2015/12/05 09:17:11","18 MB",,0
"2015/12/04 21:57:49","70 MB",,0
"2015/12/04 17:09:45","1 MB",,0
"2015/12/04 16:47:05","17 MB",,0