<table name=content_analyzer another-key=id9>  <type=global /></table><table name=content_analyzer2 another-key=id12>  <type=global /></table>    <table name=content_analyzer primary-key=id9>  <type=global /></table><table name=content_analyzer2 primary-key=id12>  <type=global /></table><table name=content_analyzer_items primary-key=id56>  <type=global /></table>if I want to extract the value of name then:grep -Po 'name=\K.*?(?=)'but how do I do it for the value of name and primary-key at the same time?For example, the below line doesn't work.grep -Po 'name=\K.*?(?=) primary-key=\K.*?(?=)'so that it looks like content_analyzer id9content_analyzer2 id12content_analyzer_items id56
Is it possible to use grep lookaroud multiple times?
text processing;grep
Using sed:$ sed -nr 's/^[^\s]+\sname=([^]+)\s.*primary-key=([^]+)>$/\1 \2/p' file.txtcontent_analyzer id9content_analyzer2 id12content_analyzer_items id56Using grep with PCRE you can get:$ grep -Po '(name|primary-key)=\K[^]+' file.txt                         content_analyzerid9content_analyzer2id12content_analyzer_itemsid56