hi,
i have two columns as follows:
129 MB
23 KB
100 B
90 GB
1 KB
4 KB
34 MB
29 MB
10 GB
the usual thing that i do is "grep" out using the units to sort things out according to prefixes then add them (with respect to their prefixes. then add the 4 sums that i get.
something like
$ grep 'MB' file.txt > file-MB.txt
$ grep 'KB' file.txt > file-KB.txt
... and so on ...
then,
$ awk -f sum.awk file-MB.txt
<outputs a number>
$ awk -f sum.awk file-KB.txt
<outputs a number>
... and so on ...
then i add all those that i get to have a sum.
is a simpler way to do this in awk in just one shot? something like
$ awk -f new_sum_awk.awk file.txt
<sum>
thanks
i have two columns as follows:
129 MB
23 KB
100 B
90 GB
1 KB
4 KB
34 MB
29 MB
10 GB
the usual thing that i do is "grep" out using the units to sort things out according to prefixes then add them (with respect to their prefixes. then add the 4 sums that i get.
something like
$ grep 'MB' file.txt > file-MB.txt
$ grep 'KB' file.txt > file-KB.txt
... and so on ...
then,
$ awk -f sum.awk file-MB.txt
<outputs a number>
$ awk -f sum.awk file-KB.txt
<outputs a number>
... and so on ...
then i add all those that i get to have a sum.
is a simpler way to do this in awk in just one shot? something like
$ awk -f new_sum_awk.awk file.txt
<sum>
thanks