Search for specific key in a file and print it

Hi All,

I have a file abc.txt
Database unique name: NEPAL
Database name: NEPAL
Services: NEPAL_COB,NEPAL_PROD

output i need is it should search "Services" and it that search "COB" word
so output i need is like
NEPAL_COB

Any attempts / ideas / thoughts from your side?

no attempts, i am new to shell scripting....
appreciate your helps ...

--- Post updated at 09:01 PM ---

Hi,
someone please help on it

--- Post updated at 09:01 PM ---

Hi,
someone please help on it

Try

awk '/Services/ {match ($0, /[A-Za-z_]*COB[A-Za-z_]*/); print substr ($0, RSTART, RLENGTH)}' file
NEPAL_COB
1 Like