最後の単語の前に(XXXX)単語を含むすべての行をキャプチャしたいです。
そしてxxxxxは数字です
/opt/OV/bin/opcagt -status
scopeux Perf Agent data collector (5102) Running
midaemon Measurement Interface daemon (5110) Running
ttd ARM registration daemon Running
perfalarm Alarm generator (5111) Running
agtrep OV Discovery Agent AGENT,AgtRep (5520) Running
coda OV Performance Core COREXT (5529) Running
opcacta OVO Action Agent AGENT,EA (5427) Running
opcle OVO Logfile Encapsulator AGENT,EA (5443) Running
opcmona OVO Monitor Agent AGENT,EA Running
opcmsga OVO Message Agent AGENT,EA (5435) Running
opcmsgi OVO Message Interceptor AGENT,EA (5553) Running
ovbbccb OV Communication Broker CORE (5352) Running
ovcd OV Control CORE (5344) Running
ovconfd OV Config and Deploy COREXT (5383) Running
私は試した
/opt/OV/bin/opcagt -status | grep [0-9]
ただし、このgrep構文は最後の単語の前の単語をキャプチャできません。
予想される結果:
scopeux Perf Agent data collector (5102) Running
midaemon Measurement Interface daemon (5110) Running
perfalarm Alarm generator (5111) Running
agtrep OV Discovery Agent AGENT,AgtRep (5520) Running
coda OV Performance Core COREXT (5529) Running
opcacta OVO Action Agent AGENT,EA (5427) Running
opcle OVO Logfile Encapsulator AGENT,EA (5443) Running
opcmsga OVO Message Agent AGENT,EA (5435) Running
opcmsgi OVO Message Interceptor AGENT,EA (5553) Running
ovbbccb OV Communication Broker CORE (5352) Running
ovcd OV Control CORE (5344) Running
ovconfd OV Config and Deploy COREXT (5383) Running
ベストアンサー1
(4-digits)<spaces>word
行の末尾にパターンを含む行を検索する
grep -E '\([0-9]{4}\)\s*\w+$'