meallhour meallhour - 9 months ago 30
Bash Question

Trying to grep instance id from within a text file

I have a text file

with the following content:

^[[34mINFO^[[0m[0000] Your engine version 1.11.1-cs1 is compatible
^[[34mINFO^[[0m[0000] We detected local components of UCP instance H7LQ:WKR5:G2PX:4F3V:JQ47:WCIG:JV4W:V6SE:4WMR:TLZN:XYWH:MIEQ
^[[31mFATA^[[0m[0000] Re-run the command with "--id H7LQ:WKR5:G2PX:4F3V:JQ47:WCIG:JV4W:V6SE:4WMR:TLZN:XYWH:MIEQ" or --interactive to confirm you want to upgrade this UCP instance.

I am now trying to grep the
UCP instance
value from
file using the following command:

grep -Po '(?<=instance=)[^"]*' bak.txt

It is not working. Please suggest the correct way.


Try this grep:

grep -oP '(?<=instance )[^"]+' bak.txt