I would like to use vim to do the following operation in vim: I would like to determine the number of entries with avg_deg greater then "'avg_deg': 5.50" from a simple .log file as well as the average of all avg_degs. Afterwards I would like to repeat the same for all entries smaller than "5.00" (the smallest entry in the log is "4.63" and the biggest is at "6.04"). Simply searching and counting the values manually is not possible in realistic time since the file is about 31 MB big.
The file contains many entries with some string in apostrophes with colon following a number but it is necessary to observe only numbers directly following the string "'avg_deg': ".
I would have copied parts of the file as example but even single variables are too big to put them here - at least my browser dies and the website doesn't react anymore when I do so.
grep
(or your favorite tools)—it's likely to be faster, not consume as much memory (31M to load the file!), and allow you trim out more correctly your search pattern. Example:<big-file grep -c "avg_deg': [5]\.[56789]"
. If you need average,awk
is good but lacks fixed/floating point support, so use something likesed 's/\([[:digit:]]\)\.\([[:digit:]]\)/\1\2/g'
to convert everything to 3-digit intsgrep
needs to use-o
since some of the results are in the same line. Afterwards I count the output with| wc -l
=><.log grep -o "'avg_deg': [4]" | wc -l
and<.log grep -o "'avg_deg': [5]\.[56789][0123456789][0123456789]*" | wc -l
and finally<.log grep -o "'avg_deg': [6]" | wc -l
. I still have to check and understand thesed
command of yours to use it.