Isso pode ser resolvido usando a extensão Perl para grep
(o -P
flag).
Para obter 3
de TrainIdentifyTechnicalError
:
$ echo "1612 TrainIdentifyBusinessError 252 TrainIdentifySuccess 23 TrainIdentifyTechnicalError" | grep -Po "[[:digit:]]+ *(?=TrainIdentifyTechnicalError)"
23
Para obter 1612
de TrainIdentifyBusinessError
$ echo "1612 TrainIdentifyBusinessError 252 TrainIdentifySuccess 23 TrainIdentifyTechnicalError" | grep -Po "[[:digit:]]+ *(?=TrainIdentifyBusinessError)"
1612