bash - Find all substrings counts in a string -


i running command returns large string. returned string looks

"foofoofoofoo verification completed: 6 reported messages. foo foo foo verification completed: 0 reported messages.foofoofoofoofoofoofoo verification completed: 2 reported messages. foo foo foo"

i looking parse output , total sum of values returned after "verification completed:", in case 8.

note: foo output & verification completed # reported messages can occur numerous times in string output.

i looking @ using awk/grep this. suggestions? not huge unix/bash guy.

using gnu awk:

awk '$1~/^[0-9]+$/{s+=$1} end{print s}' rs='verification completed:' file 8 

edit: on provided input:

awk '$1~/^[0-9]+$/{s+=$1} end{print s}' rs='verification completed: ' file 54 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -