python - How to grep for numbers from log file and do summing
I have a log file with the following strings:
2013-09-10 12:29:06 C9 T3 Update:555 Interfaces: 100 nodes: 0 ports: 0
flows: 106677
2013-09-10 12:30:07 C9 T3 Update:555 Interfaces: 100 nodes: 0 ports: 0
flows: 106281
2013-09-10 12:31:07 C9 T3 Update:555 Interfaces: 100 nodes: 0 ports: 0
flows: 108252
2013-09-10 12:32:06 C9 T3 Update:555 Interfaces: 100 nodes: 0 ports: 0
flows: 106650
2013-09-10 12:33:05 C9 T3 Update:555 Interfaces: 100 nodes: 0 ports: 0
flows: 49734
I would like to write a script to read through the file and grep only for
the # of flows (e.g. 106677) and then do a sum on them. Any ideas on best
approach? I should first try to strip only the # of flows and write to a
file and then do sum?
No comments:
Post a Comment