I have a log file with entries like
INFO 2013-08-16 13:46:48,660 Index=abc:12 insertTotal=11
INFO 2013-08-16 13:46:48,660 Index=abcd:12 insertTotal=11
INFO 2013-08-16 13:46:48,660 Index=def:134 insertTotal=11
INFO 2013-08-16 13:46:48,660 Index=abkfe insertTotal=11
INFO 2013-08-16 13:46:48,660 Index=lmkfe insertTotal=11
INFO 2013-08-16 13:46:48,660 Index=lmkfe insertTotal=11
I would like to grep and extract the words that match my pattern which is abc:<some_number>
and def:<some_number>
.
$ cat "log.txt" | grep -w "abc" -w "def" >> "failed_values.txt";
So in this case, my failed_values.txt
should only have
abc:12
def:134
The key to note is that my pattern ends with a :
followed by a number and then a space e. g. abc:122
.